Menu and Submenus in Tkinter python | python Tkinter GUI tutorial
Menu in Tkinter python | python Tkinter GUI tutorial
from tkinter import *
root = Tk()
root.geometry("785x433")
root.title("Notepad")
def myfunc():
print(("mai ek bahut hi natkhat aur shaitan function hoon"))
#use these to create to non dropdown menu
mymenu = Menu(root)
mymenu.add_command(label="file", command=myfunc)
mymenu.add_command(label="Format", command=myfunc)
mymenu.add_command(label="View", command=myfunc)
mymenu.add_command(label="help", command=myfunc)
mymenu.add_command(label="Exit", command=quit)
root.config(menu=mymenu)
root.mainloop()
Output
Submenus in Tkinter python | python Tkinter GUI tutorial
from tkinter import *
root = Tk()
root.geometry("785x433")
root.title("Notepad")
def myfunc():
print(("mai ek bahut hi natkhat aur shaitan function hoon"))
filemenu = Menu(root)
m1 = Menu(filemenu , tearoff=0)
m1.add_command(label = "New Project", command = myfunc)
m1.add_command(label = "Save", command = myfunc)
m1.add_command(label = "Save as", command = myfunc)
m1.add_command(label = "Print", command = myfunc)
root.config(menu=filemenu)
filemenu.add_cascade(label="File", menu=m1)
root.mainloop()
Output
Post a Comment