I am trying to write a python app that will switch between two views when I click on the canvas in Tkinter. I have written the views and main app as seperate objects with binds linked to the opposing view through the left mousebutton. When I run the app in Pyscripter I exceed my maximum recursion depth but am not sure why this is happening. I am relatively new to Tkinter so please forgive if this is a really ignorant question. Here is the code:
class App(object):
def __init__(self, width=256, height=256):
self.width = width
self.height = height
self.root = Tk()
self.root.title("tkinter_test01")
self.root.geometry("%sx%s"%(self.width, self.height))
self.canvas = Canvas(self.root, width=self.width, height=self.height)
self.canvas.pack()
win1(self.canvas)
class win1(object):
def __init__(self,canvas):
self.canvas=canvas
self.canvas.delete(ALL)
self.canvas.bind("<Button1>", win2(self.canvas))
self.canvas.create_line(10,10,100,100)
class win2(object):
def __init__(self,canvas):
self.canvas=canvas
self.canvas.delete(ALL)
self.canvas.bind("<Button1>", win1(self.canvas))
self.canvas.create_line(30,30,100,40)
App()