[source code] Python GUI with Tkinter - 9, 10, & 11 - Menu, Toolbar, and Status bar

+5 Bucky Roberts · September 13, 2014
from tkinter import *


def doNothing():
   print("ok ok I won't...")

root = Tk()

# Tkinter puts menus at the top by default
menu = Menu(root)
root.config(menu=menu)

subMenu = Menu(menu)
# Adds a drop down when "File" is clicked
menu.add_cascade(label="File", menu=subMenu)
subMenu.add_command(label="New Project...", command=doNothing)
subMenu.add_command(label="New...", command=doNothing)
subMenu.add_separator()
subMenu.add_command(label="Exit", command=doNothing)

editMenu = Menu(menu)
menu.add_cascade(label="Edit", menu=editMenu)
editMenu.add_command(label="Redo", command=doNothing)

# ******* Creating a Toolbar *******

toolbar = Frame(root, bg="blue")

insertButt = Button(toolbar, text="Insert Image", command=doNothing)
insertButt.pack(side=LEFT, padx=2, pady=2)
printButt = Button(toolbar, text="Print", command=doNothing)
printButt.pack(side=LEFT, padx=2, pady=2)

toolbar.pack(side=TOP, fill=X)

# ******* Creating a Status Bar for the Bottom *******

# bd is border, relief is type of border
status = Label(root, text="Preparing to do nothing", bd=1, relief=SUNKEN, anchor=W)
status.pack(side=BOTTOM, fill=X)

root.mainloop()

Post a Reply

Replies

Oldest  Newest  Rating
0 Fanta Ellyma · May 31, 2015
Excuse me i got a problem with this type can you please help me!!!!
what's wrong with it ?
thanks in advance

from Tkinter import *


def doNothing():
print("ok ok I won't...")

root = Tk()


menu = Menu(root)
root.config(menu=menu)
fileMenu = Menu(menu)

menu.add_cascade(label="File", menu=fileMenu)
fileMenu.add_command(label="New Ctrl+N", command=doNothing)
fileMenu.add_command(label="Open... Ctrl+O", command=doNothing)
fileMenu.add_command(label="Save Ctrl+S", command=doNothing)
fileMenu.add_command(label="Save as...", command=doNothing)
fileMenu.add_separator()
fileMenu.add_command(label="Page Setup...", command=doNothing)
fileMenu.add_command(label="Print... Ctrl+P", command=doNothing)
fileMenu.add_command(root.quit)

editMenu = Menu(menu)
menu.add_cascade(label="Edit", menu=editMenu)
editMenu.add_command(label="Undo Ctrl+Z", command=doNothing)
editMenu.add_command(label="Cut Ctrl+X", command=doNothing)
editMenu.add_command(label="Copy Ctrl+C", command=doNothing)
editMenu.add_command(label="Paste Ctrl+V", command=doNothing)
editMenu.add_command(label="Delete Del", command=doNothing)
fileMenu.add_separator()
editMenu.add_command(label="FInd... Ctrl+F", command=doNothing)
editMenu.add_command(label="Find Next F3", command=doNothing)
editMenu.add_command(label="Replace... Ctrl+H", command=doNothing)
editMenu.add_command(label="Go To... Ctrl+G", command=doNothing)
fileMenu.add_separator()
editMenu.add_command(label="Select All Ctrl+A", command=doNothing)
editMenu.add_command(label="Time/Date F5", command=doNothing)


helpMenu = Menu(menu)
menu.add_cascade(label="Help", command=doNothing)
helpMenu.add_command(label="Word Wrap", command=doNothing)
helpMenu.add_command(label="font...", command=doNothing)



root.mainloop()
  • 1

Python

107,017 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator