Jan-23-2018, 06:52 AM
I'm not sure it's a good idea to remove the explicit keywords when calling tkinter's methods, because the order of the arguments may be incorrect. Also you may need to keep a reference to the object you created in the init method, for example
class btn(object): def __init__(self, pos, txt, cmd, row, col, colspan, sticky): self.position = pos self.text = txt self.command = cmd self.row = row self.column = col self.columnspan = colspan self.sticky = sticky self.myVar = Button(self.position, text=self.text, command=self.cmd) self.myVar.grid(row=self.row, column=self.column, columnspan=self.columnspan, sticky=self.sticky)Concerning
myVar.bind('Button-1', myMethod)
, this call binds the event 'Button-1'
, which is the left mouse button event to the method myMethod
for the tkinter widget myVar
. Of course you can use this call only if there are a widget and a method named myVar and myMethod in the scope of the call.