class simpleapp_tk(tkinter.Tk):
def __init__(self,parent):
tkinter.Tk.__init__(self,parent)
self.parent = parent
self.initialize()
def initialize(self):
self.grid()
self.ZOOMIN = tkinter.Button(self,text="ZOOM IN")
self.ZOOMIN.grid(column=1,row=6)
self.ZOOMIN.bind("<Button-1>",self.bzoomin())
self.ZOOMIN.bind("<ButtonRelease-1>", self.brzoomin())
self.pollvar=0
def poll(self):
if self.pollvar==1:
self.ZOOMIN.after(300,self.poll())
self.OnZOOMINClick()
def brzoomin(self,event):
self.pollvar=0
def bzoomin(self,event):
self.pollvar=1
self.poll
def OnZOOMINClick(self):
....code
if __name__ == "__main__":
app = simpleapp_tk(None)
app.title('CAMERA CONTROLL v1')
app.mainloop()
I am trying to make a function to be repeatedly called while mousebutton-1 is pressed on the zoominbutton. This is supposed to be implemented through polling. When the button is clicked the poll function should be called. The poll should run continously untill mousebutton-1 is released. But the problem is that nothing happens when the button is pressed.
Edited the errors pointed out. But there must still be some problem with the code as the window itself doesn't show anymore and the code goes into an infinite loop because of the line "self.ZOOMIN.after(300,self.poll())". (This is just a part of my code)
names_with_underscoresfor methods and reservingCamelCasefor classes (among other things).