blob: e241786b08ae3575b61a3b0b266e7e1b501a9ccd (
plain)
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
|
from kivy.app import App
from kivy.lang import Builder
from time import time
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
import kivy.properties as kp
from setproperty import SetProperty
Builder.load_string('''
<Foo>:
orientation: 'vertical'
text: ''
BoxLayout:
orientation: 'horizontal'
ToggleButton:
id: btn_add
group: 'action'
text: 'add'
state: 'down'
ToggleButton:
group: 'action'
text: 'delete'
TextInput
id: value
Button:
on_press: root.update_dict(btn_add.state == 'down', value.text)
text: 'change set'
Label:
id: dictout
text: root.text
''')
class Foo(BoxLayout):
text = kp.StringProperty()
my_set = SetProperty()
def on_my_set(self, wx, my_set):
self.text = str(time()) + ' ' + str(my_set)
def update_dict(self, add, value):
if add:
self.my_set.add(value)
else:
self.my_set.discard(value)
class TestApp(App):
def build(self):
return Foo()
if __name__ == '__main__':
TestApp().run()
|