-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgrid_rowconfigure --weight.py
More file actions
37 lines (23 loc) · 953 Bytes
/
grid_rowconfigure --weight.py
File metadata and controls
37 lines (23 loc) · 953 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
29
30
31
32
33
34
35
36
37
#;==========================================
#; Title: Grid Rowconfigurtion --minisize
#; Author: @AyemunHossain
#;==========================================
import tkinter as tk
#Decleare required function
def action():
print("Action !!!")
root = tk.Tk()
#weight : weight for particular row or column when window size is shrinking
root.grid_rowconfigure(2, weight=10)
root.grid_columnconfigure(3, weight=2)
#see the changes in row 2and column 3
row = 10
column = 5
buttons = [[tk.Button() for j in range(column)] for i in range(row)]
for i in range(row):
for j in range(column):
buttons[i][j] = tk.Button(root, text="B", bg="brown", fg="white",bd=2, width = 10, command=action)
buttons[i][j].grid(row = i , column = j, sticky = 'news', padx=2, pady=2)
root.mainloop()
#Shrink the window make it bigger and see the magic
#Note if you don't user sticky = 'news' then you may don't find any changes/ unwanted changes