[Tutor] Tkinter event for changing OptionMenu items
Bernard Lebel
3dbernard at gmail.com
Thu Jul 21 20:16:05 CEST 2005
Hi Michael,
Let say I have a MenuOption, that consists of 3 items. This MenuOption
sits on top of the Tkinter window.
In the lower part, I have a bunch of widgets (text fields). When the
choose a different item from the MenuOption, it would call a function
that clears the lower part and repopulates it with new fields. My
problem is binding this callback to the event of choosing an item.
Bernard
On 7/21/05, Michael Lange <klappnase at freenet.de> wrote:
> On Thu, 21 Jul 2005 12:19:00 -0400
> Bernard Lebel <3dbernard at gmail.com> wrote:
>
> > Hello,
> >
> > I'm trying to bind an event to the changes made to an OptionMenu. Ie
> > the user chooses a different item, the rest of the Tk window gets
> > updated. To repopulate the window, a function would be called by the
> > binding.
> >
> > Any suggestion?
> >
> >
> > var1 = StringVar()
> > var1.set( aTables[0] )
> > oOptionMenu = OptionMenu( oRoot, var1, aTables[0], *aTables[1:] )
> > sTableName = var1.get()
> > oOptionMenu.bind( '<Return>', getTableColumns )
> > oOptionMenu.pack( fill = X )
> >
> > Here the '<Return>' event is obviously not the one I'm looking for,
> > but is there to illustrate what code I have so far.
> >
> >
>
> Hi Bernard,
>
> if I understand you correctly, the "<Unmap>" event of the OptionMenu's Menu may be the best
> bet for you (not very much tested though):
>
> oOptionMenu['menu'].bind('<Unmap>', getTableColumns)
>
> Otherwise you would probably have to call oOptionMenu['menu'].entryconfigure(command=...) on all menu entries.
>
> I hope this helps
>
> Michael
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list