hi coz i learning tkinter too i write some little app.
working in py3.1
---------------------------------------------------------
from tkinter import *
class ent(Entry):
def __init__(self, parent, **kwargs):
super().__init__()
self.var = StringVar()
self.config(textvariable=self.var)
self.bind('<Return>', self. check)
self.pack()
def check(self, event):
txt = self.var.get()
if txt == 'end':
event.widget.event_generate('<Tab>')
return 'break'
self.var.set('')
event.widget.focus_set()
root = Tk()
app = ent(root)
sdf = ent(root)
root.mainloop()
V Wed, 19 Jan 2011 19:32:56 +0100
Helmut Jarausch <[email protected]> napsáno:
> Hi,
>
> I have an Entry widget called Data, whose <Return> event is bound to
> a handler. If this handler recognizes invalid data I clear the
> corresponding textvariable and set the focus to itself by calling
> Data.focus_set(). Then I return "break".
> Thus I'd like to let the user re-enter his data.
> Unfortunately this doesn't work, the focus always proceeds to the next
> Entry widget.
> What am I missing?
>
> Thanks for a hint,
> Helmut.
> _______________________________________________
> Tkinter-discuss mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss