how to create a submenu in python?

Thread Solved

Join Date: Jan 2006
Posts: 237
Reputation: katharnakh is an unknown quantity at this point 
Solved Threads: 33
katharnakh's Avatar
katharnakh katharnakh is offline Offline
Posting Whiz in Training

how to create a submenu in python?

 
0
  #1
Feb 10th, 2006
how to create a submenu in python? how to use insert_cascade(index,**options)..........

please help me out.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 137
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

Re: how to create a submenu in python?

 
0
  #2
Feb 11th, 2006
This would be example from one of the tutorials:
  1. # Tkinter top-level menus
  2.  
  3. from Tkinter import *
  4. from tkMessageBox import *
  5.  
  6. # temporary function to call from menu
  7. def notdone():
  8. showerror('Not yet', 'Work in progress!')
  9.  
  10. def makemenu(win):
  11. top = Menu(win)
  12. win.config(menu=top)
  13.  
  14. file = Menu(top)
  15. file.add_command(label='New...', command=notdone, underline=0)
  16. file.add_command(label='Open...',command=notdone, underline=0)
  17. file.add_command(label='Quit', command=win.quit, underline=0)
  18. top.add_cascade(label='File', menu=file, underline=0)
  19.  
  20. edit = Menu(top, tearoff=0)
  21. edit.add_command(label='Cut', command=notdone, underline=0)
  22. edit.add_command(label='Paste', command=notdone, underline=0)
  23. edit.add_separator()
  24. top.add_cascade(label='Edit', menu=edit, underline=0)
  25.  
  26. submenu = Menu(edit, tearoff=0)
  27. submenu.add_command(label='Spam', command=win.quit, underline=0)
  28. submenu.add_command(label='Eggs', command=notdone, underline=0)
  29. edit.add_cascade(label='Stuff', menu=submenu, underline=0)
  30.  
  31. root = Tk()
  32. root.title('menu_win')
  33. makemenu(root)
  34. msg = Label(root, text='Window menu basics')
  35. msg.pack(expand=YES, fill=BOTH)
  36. msg.config(relief=SUNKEN, width=40, height=7, bg='beige')
  37. root.mainloop()
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC