Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help with Tkinter OptionMenu

72 views
Skip to first unread message

Tracy Lee Hansen

unread,
Apr 27, 1998, 3:00:00 AM4/27/98
to

Does anyone know of an example of how to use the OptionMenu widget?
Also, I need a good example of the ScrolledText widget with complete
editing...

Thanks!!

Joe Saltiel

unread,
Apr 27, 1998, 3:00:00 AM4/27/98
to Tracy Lee Hansen

Here's an example somebody sent me some time
ago. The Tkinter option menu is not very intuitive.
I believe Tix and Pmw both offer option menus that are
little easier to manipulate.

#################################################################
from Tkinter import *

class _helper:
def __init__(self, var, value):
self.__value = value
self.__var = var
def __call__(self, *args):
self.__var.set(self.__value)

root = Tk()

def theEnd():
header.set('Exiting')
File.__getitem__('menu').delete('Jorge')
print File.__getitem__('text')
root.after(2000, root.destroy)

frame = Frame(root)

header = StringVar()
header.set('flaut')
File = OptionMenu(frame, header,'An option', 'Another')
File.__getitem__('menu').add_command(label='Jorge',
command=_helper(header, 'Jorge'))
File.pack()
File.__getitem__('menu').configure(background='white')

Button(frame, text='quit', command=theEnd).pack()
frame.pack()
root.mainloop()

Fredrik Lundh

unread,
Apr 28, 1998, 3:00:00 AM4/28/98
to
>Does anyone know of an example of how to use the OptionMenu widget?

I've attached two samples. And make sure to check the newsgroup
archives as well: http://www.python.org/search

Cheers /F
fre...@pythonware.com
http://www.pythonware.com

tk038.py
tk034.py

Tracy Lee Hansen

unread,
Apr 28, 1998, 3:00:00 AM4/28/98
to


Thanks, Fredrik!

The second example was especially helpful since I want my OptionMenu
to be created from a list.

Tracy

0 new messages