from tkinter import *
root = Tk()
# Setting The Root Menu Title Bar Name
PROGRAM_NAME= "BigFoot Text Editor"
root.title(PROGRAM_NAME)
my_menu_bar = Menu(root, tearoff=0)
my_menu_bar.title = "Hunting Season"
my_menu_bar.side = 'right'
root.config(menu=my_menu_bar)
file_menu = Menu(my_menu_bar,tearoff=0)
# File Edit View and About --- Although this shit is backwards --
# Correction this shit is not backwards. When adding a menu button to the menubar \
# You need to specify the menu=<xxx> portion. Even if may be redundant otherwise the stuff \
# That is listed later under it dont appear.
my_menu_bar.add_cascade(label='File', menu=file_menu)
my_menu_bar.add_cascade(label='Edit')
my_menu_bar.add_cascade(label='View')
my_menu_bar.add_cascade(label='About')
#Removed After Testing For Forgotten Reason. So Ignore
# Testing. So this weird thing actually gave me a submenu with the ">" under the File Menu
#file_menu.add("cascade", label="Inside Test", font="Ubuntu", underline=1)
# Attempting To Add a Submenu to The File Menu 'Inside Test' cascade to the thing
insideTest_submenu = Menu(file_menu, tearoff=0) #Added as a Menu to a Menu. Get it? Attaching to parent file_menu (a cascade that acts as the file menu drop down)
# Immediately adding a "command" (ie menu item, ie menu entry) to the just created Menu within the Menu
insideTest_submenu.add("command", label="Hope This Works To Add To The SubMenu", font="Ubuntu")
# cONVERTING THE COMMENTED ABOVE TO ADD THE SUBMENU PORTIONS
file_menu.add("cascade", label="Inside Test", font="Ubuntu", underline=1, menu=inside_submenu)
# Testing Pass 2. Result
file_menu.add("command", label="Test using Command", font="Ubuntu", underline=1)
file_menu.add("separator")
file_menu.add_command(label='New', accelerator='Ctrl+N',
compound='left', underline=0)
file_menu.add_command(label='Open', accelerator='Ctrl+O',
compound='left', underline=0)
file_menu.add_command(label='Save', accelerator='Ctrl+S',
compound='left', underline=0)
file_menu.add_command(label='Save as', accelerator='Shift+Ctrl+S')
file_menu.add_separator()
file_menu.add_command(label='Exit', accelerator='Alt+F4')
root.mainloop()
Comments
0 B
|0 👍
/0 👎
0 B
|👍
/👎