forked from flatplanet/Intro-To-TKinter-Youtube-Course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu_frame.py
59 lines (44 loc) · 1.57 KB
/
menu_frame.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
47
48
49
50
51
52
53
54
55
56
57
58
from tkinter import *
root = Tk()
root.title('Codemy.com - Learn To Code!')
root.iconbitmap('c:/gui/codemy.ico')
root.geometry("400x400")
my_menu = Menu(root)
root.config(menu=my_menu)
# click command
def our_command():
my_label = Label(root, text="You Clicked a Dropdown Menu!").pack()
# File New Function
def file_new():
hide_all_frames()
file_new_frame.pack(fill="both", expand=1)
my_label = Label(file_new_frame, text="You Clicked the File >> New Menu!").pack()
# Edit Cut
def edit_cut():
hide_all_frames()
edit_cut_frame.pack(fill="both", expand=1)
my_label = Label(edit_cut_frame, text="You Clicked the Edit >> Cut Menu!").pack()
# Hide all frames
def hide_all_frames():
file_new_frame.pack_forget()
edit_cut_frame.pack_forget()
#Create a menu item
file_menu = Menu(my_menu)
my_menu.add_cascade(label="File", menu=file_menu)
file_menu.add_command(label="New...", command=file_new)
file_menu.add_separator()
file_menu.add_command(label="Exit", command=root.quit)
# Create an edit menu item
edit_menu = Menu(my_menu)
my_menu.add_cascade(label="Edit", menu=edit_menu)
edit_menu.add_command(label="Cut", command=edit_cut)
edit_menu.add_command(label="Copy", command=our_command)
#Create an Options menu item
option_menu = Menu(my_menu)
my_menu.add_cascade(label="Options", menu=option_menu)
option_menu.add_command(label="Find", command=our_command)
option_menu.add_command(label="Find Next", command=our_command)
# Create some frames
file_new_frame = Frame(root, width=400, height=400, bg="red")
edit_cut_frame = Frame(root, width=400, height=400, bg="blue")
root.mainloop()