Entry widget bind problems
vector
Vector180W at netscape.net
Tue Apr 1 19:37:14 EST 2003
newbie
PythonWin 2.2.2
Im a little confused with an entry widget bind. I had it working b4 but
In an attempt to tidy up the code I have confused the class/callback
reference or something.
As you can see from the text below, there is a MyFrame instance which
builds the TK Gui window, in which a frame contains an entry widget.
after typing in text into the entry widget a <return> event(enter key)
is supposed to run the doEntry, but all i get this error.
what am i doing wrong?
##error
p=page.get() #gets all text
AttributeError: Event instance has no attribute 'get'
##
def doEntry(page,*args):
"""Gets text from Entry widget on <enter> hit"""
p=page.get() #gets all text
print p #print it
page.delete(0,END) #clear entry widget
def entry(self,side,initTxt):
"""Make simple entry widget.Requires initial text"""
self.entrVar = StringVar() #assign variable
w=Entry(self, relief=SUNKEN,textvariable=self.entrVar,
font=(('MS','Sans','Serif'),'6'))
#w.bind('<Return>',doEntry,self) #tried to bind it here too
w.pack(side=side, expand=YES,fill=BOTH)
w.insert(0,initTxt)
return w
class MyFrame(Frame):
def __init__(self,master):
Frame.__init__(self,master)
..........snip
self.outEntry=entry(Oframe,LEFT,'Enter_Command')
self.outEntry.bind('<Return>',doEntry)
......endsnip
ALSO tried
self.outEntry.bind('<Return>',doEntry,self.outEntry)
More information about the Python-list
mailing list