Dec-06-2018, 10:53 AM
This is how my app looks like in the image below
![[Image: 4jBdPFH]](https://ibb.co/4jBdPFH)
WHAT I AM TRYING TO DO:
I am trying to create a desktop app using tkinter where I have a Entry (Textbox) to enter a module name and press on a button which calls a function that does dir(given_module_name) and displays the list in a Listbox.
Questions:
1) Somehow, when I first run my program, the Listbox is automatically being populated before pressing the button. I am not sure why this is happening.
2) When I click on the button, nothing is happening. Why
I am noob in python and I am sure I am doing something wrong somewhere but not able to figure out where.
Thanks,
Om
Here is my code:
WHAT I AM TRYING TO DO:
I am trying to create a desktop app using tkinter where I have a Entry (Textbox) to enter a module name and press on a button which calls a function that does dir(given_module_name) and displays the list in a Listbox.
Questions:
1) Somehow, when I first run my program, the Listbox is automatically being populated before pressing the button. I am not sure why this is happening.
2) When I click on the button, nothing is happening. Why
I am noob in python and I am sure I am doing something wrong somewhere but not able to figure out where.
Thanks,
Om
Here is my code:
from tkinter import * window = Tk() window.title("Python Help") def lib_func(lib): print("Entered lib_func()----->") func_list = dir(lib) for item in func_list: list1.insert(END, item) #lib_name="os" #lib_funcs(lib_name) text_label = Label(window,text="Enter lib") text_label.grid(row=0,column=0) str_var=StringVar() #print("str_val type is: ",type(str_var)) #str_val type is: <class 'tkinter.StringVar'> # This part is confusing where the text typed in text_entry is fetched from str_val text_entry = Entry(window,textvariable=str_var) text_entry.grid(row=0, column=1) list1=Listbox(window, height=30,width=35) list1.grid(row=2,column=0,rowspan=6,columnspan=2) enter_button = Button(window,text="Enter",command=lib_func(str_var.get())) enter_button.grid(row=0,column=2) window.mainloop()