-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathframe_demo.py
52 lines (43 loc) · 1.95 KB
/
frame_demo.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
# this program creates labels in two different frames.
import tkinter
class MyGUI:
def __init__(self):
# create the main window widget.
self.main_window=tkinter.Tk()
# create two frames, one for the top of the
# windows, and one for the bottom.
self.top_frame=tkinter.Frame(self.main_window)
self.bottom_frame=tkinter.Frame(self.main_window)
# create three Label widgets for the top frame.
self.label1=tkinter.Label(self.top_frame, \
text="Winken")
self.label2=tkinter.Label(self.top_frame, \
text="Blinken")
self.label3=tkinter.Label(self.top_frame, \
text="Nod")
# pack the labels that are in the top frame.
# use the side="top" argument to stack them one
# on top of the other.
self.label1.pack(side="top")
self.label2.pack(side="top")
self.label3.pack(side="top")
# create three Label widgets for the bottom frame.
self.label4=tkinter.Label(self.top_frame, \
text="Winken")
self.label5=tkinter.Label(self.top_frame, \
text="Blinken")
self.label6=tkinter.Label(self.top_frame, \
text="Nod")
# pack the labels that are in the bottom frame.
# use the side="left" argument to arrange them
# horizontally from the left of the frame.
self.label4.pack(side="left")
self.label5.pack(side="left")
self.label6.pack(side="left")
# yes, we have to pack the frames too!
self.top_frame.pack()
self.bottom_frame.pack()
# enter the tkinter main loop.
tkinter.mainloop()
# create an instance of the MyGUI class.
my_gui=MyGUI()