-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlabel_frame_example.py
27 lines (20 loc) · 998 Bytes
/
label_frame_example.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
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
# we create a basic label and pin it to the grid based on x,y coordinates
tk.Label(root, text="label on root").grid(column=0, row=7)
# we create a basic Frame and pin it to the root
tk_frame = tk.Frame(root)
tk_frame.grid(column=1, row=8)
# we create 3 basic labels, and pin them in an horizontal fashion inside the tk_frame
tk.Label(tk_frame, text="label_1").grid(column=0, row=0)
tk.Label(tk_frame, text="label_2").grid(column=1, row=0)
tk.Label(tk_frame, text="label_3").grid(column=2, row=0)
# we create a ttk Frame (it can have a title) and pin it to the root
ttk_frame = ttk.LabelFrame(root, text="My Label Frame")
ttk_frame.grid(column=1, row=9)
# we create 3 more basic Labels, and pin them in a vertical fashion inside the ttk_frame
tk.Label(ttk_frame, text="label_1").grid(column=0, row=0)
tk.Label(ttk_frame, text="label_2").grid(column=0, row=1)
tk.Label(ttk_frame, text="label_3").grid(column=0, row=2)
root.mainloop()