| | |
how to create a submenu in python?
Thread Solved |
This would be example from one of the tutorials:
Python Syntax (Toggle Plain Text)
# Tkinter top-level menus from Tkinter import * from tkMessageBox import * # temporary function to call from menu def notdone(): showerror('Not yet', 'Work in progress!') def makemenu(win): top = Menu(win) win.config(menu=top) file = Menu(top) file.add_command(label='New...', command=notdone, underline=0) file.add_command(label='Open...',command=notdone, underline=0) file.add_command(label='Quit', command=win.quit, underline=0) top.add_cascade(label='File', menu=file, underline=0) edit = Menu(top, tearoff=0) edit.add_command(label='Cut', command=notdone, underline=0) edit.add_command(label='Paste', command=notdone, underline=0) edit.add_separator() top.add_cascade(label='Edit', menu=edit, underline=0) submenu = Menu(edit, tearoff=0) submenu.add_command(label='Spam', command=win.quit, underline=0) submenu.add_command(label='Eggs', command=notdone, underline=0) edit.add_cascade(label='Stuff', menu=submenu, underline=0) root = Tk() root.title('menu_win') makemenu(root) msg = Label(root, text='Window menu basics') msg.pack(expand=YES, fill=BOTH) msg.config(relief=SUNKEN, width=40, height=7, bg='beige') root.mainloop()
![]() |
Similar Threads
- Projects for the Beginner (Python)
- Starting Python (Python)
- calling Python function from C/C++ (Python)
- raw_input StartsWith and other questions (Python)
- Create a Structure (Python)
- using distutils to install a python module (Python)
- Creating submenus in table cells (JavaScript / DHTML / AJAX)
Other Threads in the Python Forum
- Previous Thread: File Dialog window, save dialog window
- Next Thread: Searching for a good network Library
| Thread Tools | Search this Thread |
alarm app assignment avogadro beginner bluetooth character cipher cmd code customdialog cx-freeze data decimals dictionary directory dynamic error examples exe file float format function generator getvalue gnu graphics gui halp homework http ideas images import input ip itunes java keycontrol leftmouse line linux list lists loop maintain maze millimeter module mouse number numbers output parsing path port prime programming projects push py2exe pygame pyglet pyqt python queue random recursion schedule screensaverloopinactive script scrolledtext slicenotation sqlite ssh string strings sudokusolver terminal text threading time tlapse tuple tutorial ubuntu unicode url urllib urllib2 variable variables ventrilo vigenere web webservice wikipedia wxpython xlib






