-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex7.py
More file actions
28 lines (22 loc) · 891 Bytes
/
Copy pathex7.py
File metadata and controls
28 lines (22 loc) · 891 Bytes
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
import tkinter as tk
window = tk.Tk()
# Create a 3*3 grid of frames
for i in range(3):
for j in range(3):
frame = tk.Frame(
master=window,
relief=tk.RAISED,
borderwidth=1
)
# Key operative here is grid(), used to attach frames to window
# Also pads frame in x & y direction in PIXELS
frame.grid(row=i, column=j, padx=5, pady=5)
# Label each sub grid by it's y,x coordinates
label = tk.Label(master=frame, text=f"Row {i}\nColumn {j}")\
# Attaches each label to its master grame
# Also pads label in x & y direction in PIXELS
label.pack(padx=5, pady=5)
# Insight: even though .grid() is called on each Frame object, the geometry
# manager applies to the window object
# Also, the layout of each frame is controlled with the .pack() geometry manager
window.mainloop()