TKinter question - A combo box / menu question
Paul Sage
psage at ncaustin.com
Tue Mar 26 17:29:12 EST 2002
First, let me apologize for sending this in HTML the first time. I have
had a few responses on this, but nothing turns up. Basically, I want
to pop-up a ComboDialogBox as a result of a Menu selection. What I am
doing is creating the ComboDialogBox everytime it gets to the "command"
portion of the Menu option.
Here is most of the relevant code:
class mainWindow:
#Build the components into the main window
def __init__(self, master):
# Begin creation of the main menu items here.
# File section.
mbar = Menu(master, tearoff=0)
master['menu'] = mbar
frameForDialog = frame(master, N)
file_menu = Menu(mbar, tearoff=0)
file_menu.add_command(label='Load Form',
command=self.open_file(frameForDialog))
file_menu.add_command(label='Save Form', command=self.save_file)
file_menu.add_command(label='New Form', command=self.new_file)
file_menu.add_separator()
file_menu.add_command(label='Quit', command=self.quit_file)
mbar.add_cascade(label='File', underline=0, menu=file_menu)
# End top pull down menu selections.
statEditorFrame = frame(master, N)
statEditor = StatEditor(statEditorFrame)
def open_file(self, parent):
#Need the listofcharacters to be a tuple sequence.
from char_edit_combo_load import *
forms = []
listOfCharacters = tuple(getFiles(forms))
dialog = Pmw.ComboBoxDialog(parent, title = "Character Load",
buttons = ('OK', 'Cancel'),
defaultbutton = 'OK',
combobox_labelpos=N,
label_text="Please select a character",
scrolledlist_items=listOfCharacters,
listbox_width=22)
dialog.withdraw()
result=dialog.activate()
# The function has now opened seen the selection, time to open the
file.
if result == 'OK':
return(readObjectFromFile(dialog.get()))
else:
return(None)
def save_file(self):
#This will save the file off
print('SF: Stub')
def quit_file(self):
#This will save the file off
print('SF: Stub')
def new_file(self):
#This will save the file off
print('NF: Stub')
def add_level(self):
#This will save the file off
print('SF: Stub')
def subtract_level(self):
#This will save the file off
print('NF: Stub')
root=Tk()
root.title('Character Generator')
Pmw.initialise()
topWindow = mainWindow(root)
root.mainloop()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20020326/05ae7eaa/attachment.html>
More information about the Python-list
mailing list