-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathres_wids.py
80 lines (59 loc) · 2.33 KB
/
res_wids.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import tkinter as tk
from tkinter import font
class ResponsiveFrame(tk.Frame):
def resize(self, event):
multipler = self.root.RES[self.root.SS]
border_size = int(self.border_size*multipler)
self.config(highlightthickness = border_size)
if self.winfo_manager() == 'grid':
self.grid_configure({
i: int(self.grid_config[i] * multipler) for i in ['ipadx', 'ipady', 'padx', 'pady']
})
def grid(self, cnf={}, **kw):
super().grid(cnf={}, **kw)
self.grid_config = self.grid_info()
def __init__(self, master=None, cnf={}, **kw):
self.root, self.border_size = kw.pop('root'), kw.get('highlightthickness', 0)
super().__init__(master, cnf, **kw)
self.bind('<Configure>', self.resize)
class ResponsiveLabel(tk.Label):
def resize(self, event):
multipler = self.root.RES[self.root.SS]
font_data = {
**self.font, 'size': int(self.font['size']*multipler)
}
self.config(font = font.Font(**font_data))
if self.winfo_manager() == 'grid':
self.grid_configure({
i: int(self.grid_config[i] * multipler) for i in ['ipadx', 'ipady', 'padx', 'pady']
})
def grid(self, cnf={}, **kw):
super().grid(cnf={}, **kw)
self.grid_config = self.grid_info()
def __init__(self, master=None, cnf={}, **kw):
self.root, self.font = kw.pop('root'), kw.pop('font').actual()
super().__init__(master, cnf, **kw)
self.bind('<Configure>', self.resize)
class ResponsiveEntry(tk.Entry):
def resize(self, event):
multipler = self.root.RES[self.root.SS]
font_data = {
**self.font, 'size': int(self.font['size']*multipler)
}
self.config(font = font.Font(**font_data))
if self.winfo_manager() == 'grid':
self.grid_configure({
i: int(self.grid_config[i] * multipler) for i in ['ipadx', 'ipady', 'padx', 'pady']
})
def set_value(self, value):
self.config(state="normal")
self.delete(0, "end")
self.insert(0, value)
self.config(state="disabled")
def grid(self, cnf={}, **kw):
super().grid(cnf={}, **kw)
self.grid_config = self.grid_info()
def __init__(self, master=None, cnf={}, **kw):
self.root, self.font = kw.pop('root'), kw.pop('font').actual()
super().__init__(master, cnf, **kw)
self.bind('<Configure>', self.resize)