forked from slightlynybbled/tk_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkey_value.py
More file actions
43 lines (34 loc) · 1.01 KB
/
key_value.py
File metadata and controls
43 lines (34 loc) · 1.01 KB
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
import tkinter as tk
import tk_tools
root = tk.Tk()
# create the key-value with a title
kve0 = tk_tools.KeyValueEntry(
root,
title='Key/Value 0',
keys=['Buckets', 'Dollars', 'Hens'],
unit_labels=['buckets', 'dollars', 'hens'],
)
kve0.grid(row=0)
# create another key-value set without a title and with no units
kve1 = tk_tools.KeyValueEntry(
root,
keys=['Baskets', 'Cows']
)
kve1.grid(row=1)
# create a key-value with some entries disabled, then load values into each
kve2 = tk_tools.KeyValueEntry(
root,
title='Static Key Value',
keys=['Buckets', 'Dollars', 'Hens'],
unit_labels=['buckets', 'dollars', 'hens'],
enables=[False, False, True]
)
kve2.grid(row=2)
kve2.load({'Buckets': 'x', 'Dollars': 'y', 'Hens': 'z'})
def get_values():
print('kve0: {}'.format(kve0.get()))
print('kve1: {}'.format(kve1.get()))
print('kve2: {}'.format(kve2.get()))
get_values_btn = tk.Button(root, text='Retrieve Values', command=get_values)
get_values_btn.grid(row=3)
root.mainloop()