I'm trying to bind a Tkinter widget to a method in another file. I'm not quite sure how to do this, but let me show you what I have so far.
#!/usr/bin/python
# File1.py
from Tkinter import *
import File2
class MyFile:
def __init__(self):
master = Tk()
obj = File2.DoStuff(master)
obj.pack()
master.mainloop()
def entryClick(self):
print "I was clicked!"
myclass = MyFile()
#!/usr/bin/python
# File2.py
from Tkinter import *
class DoStuff(Frame):
def __init__(self, master):
Frame.__init__(self, master)
frame = Frame(self); frame.pack(side=LEFT, expand=YES, fill=BOTH)
myEntry = Entry(frame)
myEntry.pack()
#myEntry.bind('<Button-1>', ?) # I want to bind this to the entryClick method of File1
As you can see in line 12 of File2, I am trying to bind a click inside the widget to the "entryClick" method in File1. How can I do this?
Thanks in advance.