Variable length parameters for event method : Event : Tkinker PYTHON TUTORIALS


PYTHON TUTORIALS » Tkinker » Event »

 

Variable length parameters for event method


Variable length parameters for event method
from Tkinter import *

class MyApp:
  def __init__(self, parent):
    self.myParent = parent   
    self.myContainer1 = Frame(parent)
    self.myContainer1.pack()
    
    button_name = "OK"
    self.button1 = Button(self.myContainer1,
      command=self.buttonHandler(button_name, 1"A"))
      
    self.button1.configure(text=button_name, background="green")  
    self.button1.pack(side=LEFT)
    self.button1.focus_force()  
    
    button_name = "Cancel"
    self.button2 = Button(self.myContainer1, 
      command=self.buttonHandler(button_name, 2"B")) 
       
    self.button2.configure(text=button_name, background="red")
    self.button2.pack(side=LEFT)   
        
    
  def buttonHandler(self, arg1, arg2, arg3):   
    print arg1, arg2, arg3
    
   def buttonHandler_a(self, event, arg1, arg2, arg3):
    print "event:", event
    self.buttonHandler(arg1, arg2, arg3)
    
root = Tk()
myapp = MyApp(root)
root.mainloop()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Tkinker
» Event