-
Notifications
You must be signed in to change notification settings - Fork 0
/
label_block.py
40 lines (28 loc) · 1.26 KB
/
label_block.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
from tkinter import ttk
class LabelBlock(ttk.Label):
def __init__(self, parent):
ttk.Label.__init__(self, parent)
def set_content(self, name=None, content=None, special_content=None):
self.config(text=name)
for record in content:
self.config(text=self.cget('text') + '\n' + str(record[name]))
class LabelBlockDict(LabelBlock):
def __init__(self, parent):
LabelBlock.__init__(self, parent)
def set_content(self, name=None, content=None, special_content=None):
self.config(text=name)
if name == 'PARAMETER':
for parameter_name in content:
self.config(text=self.cget('text') + '\n' + str(parameter_name))
elif name == 'VALUE':
for parameter_value in content.values():
self.config(text=self.cget('text') + '\n' + str(parameter_value))
class TitleBlock(LabelBlock):
def __init__(self, parent):
LabelBlock.__init__(self, parent)
self.config(font=(None, 20, 'bold'))
def set_content(self, name=None, content=None, special_content=None):
if name and special_content:
self.config(text=str(name) + ': ' + str(special_content))
elif special_content:
self.config(text=special_content)