python - multiple commands on button press -


how change code can have start function called drop_down_menu()

done_btn = button(root, text = "done", command = lambda: root.destroy())        done_btn.pack() 

i have looked @ previous articles use function , have operations there says root not defined.

you need create function , pass root variable it:

def myfunction(root):     root.destroy()     drop_down_menu()  done_btn = button(root, text = "done", command = lambda: myfunction(root))        done_btn.pack() 

for more details on how use callbacks in tkinter here's tutorial. here's example tutorial on how use callback parameter:

def callback(number):     print "button", number  button(text="one",   command=lambda: callback(1)).pack() button(text="two",   command=lambda: callback(2)).pack() button(text="three", command=lambda: callback(3)).pack()   

hope helps.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -