Tkinter menu button example

Below is Python Tkinter menu button and submenu example.

from tkinter import *

root = Tk()

def random():
    print("this is a statement")

mainMenu=Menu(root)

root.configure(menu=mainMenu)

subMenu = Menu(mainMenu)
mainMenu.add_cascade(label="File", menu = subMenu)

subMenu.add_command(label="Random Func", command=random)

subMenu.add_command(label="New File", command=random)

subMenu.add_separator()

subMenu.add_command(label="Supercalarfragilistic", command=random)

root.mainloop()



Comments

Popular posts from this blog

How to write to a file in Kotlin

Python Tkinter example