how to return value from button clicked by python

chen tao ct19850519 at gmail.com
Fri Sep 11 11:19:45 EDT 2009


Hi,
     I have several buttons, I want to realize: when I click first
button, the button will call a function, and the function should
return some parameter value, because I need this value for the other
buttons.
    I tried the button.invoke() function, it almost got it...however,
I only want it returns value when the button clicked, but because the
program is in the class _ini_ function, so it always runs once before
I click the button...
    Any one can give me some suggestions?
    My scripts is like this:
def call1():
....
     return para

def app():
...
class GUI():
      def __init__(self,parent = None):
         ........
         B1 = Button(self.master, text ='browse...', command = call1)
         B1.grid(row=len(self.user_input_index),column = 3,sticky=W)
         print self.B1.invoke()
         call2 = lambda: app(self.B1.invoke())
         B2 = Button(self.master, text ='browse...',command = call2)



More information about the Python-list mailing list