forked from flatplanet/Intro-To-TKinter-Youtube-Course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_menu.py
46 lines (34 loc) · 1.01 KB
/
delete_menu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from tkinter import *
root = Tk()
root.title('Codemy.com - Delete Menus')
root.iconbitmap('c:/gui/codemy.ico')
root.geometry('500x500')
def new():
pass
def open():
pass
# Disable the New Menu Item
def disable_new():
file_menu.entryconfig("New", state="disabled")
# Enable the New Menu Item
def enable_new():
file_menu.entryconfig("New", state="normal")
# Delete New Menu Item
def delete_new():
file_menu.delete("New")
# Create Menu
my_menu = Menu(root)
root.config(menu=my_menu)
# Add Menu Items
file_menu = Menu(my_menu, tearoff=False)
my_menu.add_cascade(label="File", menu=file_menu)
# Add dropdown items
file_menu.add_command(label="New", command=new)
file_menu.add_command(label="Open", command=open)
disable_button = Button(root, text="Disable New", command=disable_new)
disable_button.pack(pady=50)
enable_button = Button(root, text="Enable New", command=enable_new)
enable_button.pack(pady=10)
delete_new_button = Button(root, text="Delete New", command=delete_new)
delete_new_button.pack(pady=20)
root.mainloop()