python - tkinter call two functions -


is possible make tkinter button calls 2 function?

some thing maybe?:

from tkinter import *  admin = tk() def o():     print '1'  def t():     print '2' button = button(admin, text='press', command=o, command=t) button.pack() 

make new function calls both:

def o_and_t():     o()     t() button = button(admin, text='press', command=o_and_t) 

alternatively, can use fun little function:

def sequence(*functions):     def func(*args, **kwargs):         return_value = none         function in functions:             return_value = function(*args, **kwargs)         return return_value     return func 

then can use this:

button = button(admin, text='press', command=sequence(o, t)) 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -