Tkinter and setting focus
richard_chamberlain
richard_chamberlain at ntlworld.com
Tue Jun 20 18:21:04 EDT 2000
Hi Rony,
You could just generate your own tab event (I presume that's the behaviour
you want)
So:
def validate(self,event):
# do some validation
self.field.event_generate('<Tab>')
Richard
BuCoDI-Rony Steelandt <rsteelandt at bucodi.com> wrote in message
news:394F860E.EF6042D6 at bucodi.com...
>
> I have created a class wich expands the standard entry widget.
> In that class i did a override of the return key to do some validation
> of my entry
>
> self.entry.bind(<return>,self.validate)
>
> The validation routine works fine, but now comes my problem
>
> I want at the end of the validation, if validation is ok set the focus
> to the next entry widget in the form.
> I searched documentation but didn't find anything on this.
> The problem is since my class is a general class, i don't know in the
> class wich widget is the next to put the
> focus on.
> Here is some code to show what i'm doing:
> class numentry:
> def
>
__init__(self,parent,rw,clmn,wdt,relf=SUNKEN,mask='$',min=0,max=999999999):
>
> self.w = wdt
> self.m = mask
> self.min = min
> self.max = max
> self.field = Entry(parent,relief=SUNKEN,width=wdt)
> self.field.grid(row=rw,column=clmn)
> self.field.bind("<Return>",self.validate)
> self.returnval=''
> self.ind = 0
> self.pointindex = 0
>
>
> def validate(self,event):
> # do some validation
> ===> here i want to set the focus to the next widget
>
>
> #main
> frame = Frame(root,width=100,height=100)
> # frame.bind("<Up>",callback)
> frame.pack()
> f=numentry(frame,1,1,10,SUNKEN,'0000.00',5)
> f2=numentry(frame,2,1,10,SUNKEN,'0000.00')
> root.mainloop()
>
>
> I'm realy sticked on that ?????
> Anyone has a idea how to do that
>
> Rony Steelandt
> --
> ======================================================
> Bureau de Conseil et de Développement Informatique
> 2, Rue Henri Avril
> 22480 Saint - Nicolas du Pelem
>
> Tél : +33.2.96.29.79.08
> Fax : +33.2.96.29.79.09
>
> e-mail : bucodi at worldnet.fr
> ======================================================
>
>
More information about the Python-list
mailing list