-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpack_grid_forget.py
46 lines (28 loc) · 981 Bytes
/
pack_grid_forget.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
from tkinter import *
root = Tk()
root.title("Pack/Grid Forget and Destroy - Intro To Tkinter")
root.iconbitmap('images/tkinter.ico')
root.geometry('500x350')
# Pack/Grid Forget and Destroy
def hide():
my_frame.pack_forget()
def show():
my_label.grid(row=0, column=0, columnspan=3, pady=20)
def destroy():
my_label.destroy()
# Create a quick frame
my_frame = Frame(root)
my_frame.pack(pady=50)
# Create a label
my_label = Label(my_frame, text="Hello World", font=("Helvetica", 24))
my_label.grid(row=0, column=0, columnspan=3, pady=20)
# Grid Stuff
my_button3 = Button(my_frame, text="Hide", command=hide)
my_button4 = Button(my_frame, text="Show", command=show)
my_button5 = Button(my_frame, text="Destroy Forever", command=destroy)
my_button3.grid(row=1, column=0)
my_button4.grid(row=1, column=1, padx=20)
my_button5.grid(row=1, column=2)
my_label2 = Label(root, text="My Name Is John Elder", font=("Helvetica", 24))
my_label2.pack(pady=20)
root.mainloop()