Here we are providing basic tutorial in Tkinter on how to create a status bar in a Tkinter GUI application.

Sample code

The following Tkinter code will demonstrate the same:

from tkinter import *

def doNothing():
    print("Ok Ok I wont")

root = Tk()

# Main Menu

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

subMenu = Menu(menu)
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)

# 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)

# Status bar

status = Label(root, text="Status bar...", bd=1, relief=SUNKEN, anchor=W)
status.pack(side=BOTTOM, fill=X)

root.mainloop()


In the above code, the code for the Main menu had been explained already in the topic of Creating a dropdown menu and the code for the Toolbar had been explained already in the topic of Creating a toolbar. In the next few lines of code, we created a status bar called status using the pre-defined method in Tkinter known as Label which takes root window as a parameter. Other new parameters are bd that is used for inserting border, relief is used to set the position of the status bar in the GUI window and anchor is used to set the position of text in the status bar, W value stands for West direction. At last, status is packed using the function pack() at required positions.

Output

output