4 Replies - 3617 Views - Last Post: 16 April 2015 - 02:23 AM

#1 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2972
  • View blog
  • Posts: 11,223
  • Joined: 15-July 08

Menus in Tkinter

Posted 15 August 2009 - 07:45 PM

Description: You need to have Tkinter on your system, which is done by default,so you probably dont have to worry about that much.This snippet shows an exampl of how menus can be implemented in Tkinter
from Tkinter import *

root = Tk()

# Set up the main meunubar
menubar = Menu(root)

# Set up the file menu
filemenu = Menu(menubar)

# Now we add the menu commands such as open, save....
# just add them on by writing this line of code
filemenu.add_command(label="Quit", # Label is the name that appears
                     command=root.quit, # This is a reference to the 
                                        # function not a call to it!
                     accelerator="Ctrl+Q") # This is the 'hotkey that 
                                           #is on the right side of the menu button

# Add any additional buttons here, or add a separator with add_separator()
                                           
# Now we add the menu to the main menubar
menubar.add_cascade(label="File",menu=filemenu)

# Finally, add the menubar to the Tk Frame.
root.config(menu=menubar)

root.mainloop()


Is This A Good Question/Topic? 1
  • +

Replies To: Menus in Tkinter

#2 Buzzer   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 24-December 11

Re: Menus in Tkinter

Posted 25 December 2011 - 01:31 AM

Simple ! And Effective ! I have learned to create basic menu in 2 minutes ! Great ! Thanks
Was This Post Helpful? 0
  • +
  • -

#3 Buzzer   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 24-December 11

Re: Menus in Tkinter

Posted 25 December 2011 - 01:32 AM

Simple ! And Effective ! I have learned to create basic menu in 2 minutes ! Great ! Thanks
Was This Post Helpful? 0
  • +
  • -

#4 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2972
  • View blog
  • Posts: 11,223
  • Joined: 15-July 08

Re: Menus in Tkinter

Posted 25 December 2011 - 08:46 AM

Hey Buzzer! Glad you found it helpful.
Was This Post Helpful? 0
  • +
  • -

#5 chetherebel   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 8
  • Joined: 02-April 15

Re: Menus in Tkinter

Posted 16 April 2015 - 02:23 AM

I was trying to get a basic understanding of GUI's in Python.
This helped me quite a lot.
Thanks man!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1