943,188 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Marked Solved
  • Views: 4121
  • Python RSS
Feb 10th, 2006
0

how to create a submenu in python?

Expand Post »
how to create a submenu in python? how to use insert_cascade(index,**options)..........

please help me out.
Similar Threads
Reputation Points: 19
Solved Threads: 34
Posting Whiz in Training
katharnakh is offline Offline
237 posts
since Jan 2006
Feb 11th, 2006
0

Re: how to create a submenu in python?

This would be example from one of the tutorials:
Python Syntax (Toggle Plain Text)
  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()
Reputation Points: 404
Solved Threads: 180
Nearly a Posting Virtuoso
bumsfeld is offline Offline
1,422 posts
since Jul 2005
Feb 22nd, 2010
0

submenu

hi i was wandering if you wanted to keep track of where someone clicked in the menu how would you go about doing that?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
skydiverman05 is offline Offline
1 posts
since Feb 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Toolbar inside TAB
Next Thread in Python Forum Timeline: Please, help me with my dictionary problem...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC