5
5
6
6
import ugfx , badge , utime as time
7
7
8
- wait_for_interupt = True
8
+ wait_for_interrupt = True
9
9
10
10
def notice (text , title = "SHA2017" , close_text = "Close" , width = 296 , height = 128 , font = "Roboto_Regular12" ):
11
11
prompt_boolean (text , title = title , true_text = close_text , false_text = None , width = width , height = height , font = font )
@@ -16,7 +16,7 @@ def prompt_boolean(text, title="SHA2017", true_text="Yes", false_text="No", widt
16
16
if 'false_text' is set to None only one button is displayed.
17
17
If both 'true_text' and 'false_text' are given a boolean is returned
18
18
"""
19
- global wait_for_interupt
19
+ global wait_for_interrupt
20
20
21
21
window = ugfx .Container ((ugfx .width () - width ) // 2 , (ugfx .height () - height ) // 2 , width , height )
22
22
window .show ()
@@ -41,8 +41,8 @@ def prompt_boolean(text, title="SHA2017", true_text="Yes", false_text="No", widt
41
41
window .show ()
42
42
ugfx .flush ()
43
43
44
- wait_for_interupt = True
45
- while wait_for_interupt :
44
+ wait_for_interrupt = True
45
+ while wait_for_interrupt :
46
46
if buttons .is_triggered ("BTN_A" ): return True
47
47
if buttons .is_triggered ("BTN_B" ): return False
48
48
time .sleep (0.2 )
@@ -59,7 +59,7 @@ def prompt_text(description, init_text = "", true_text="OK", false_text="Back",
59
59
60
60
Returns None if user aborts with button B
61
61
"""
62
- global wait_for_interupt
62
+ global wait_for_interrupt
63
63
64
64
window = ugfx .Container (int ((ugfx .width ()- width )/ 2 ), int ((ugfx .height ()- height )/ 2 ), width , height )
65
65
@@ -89,8 +89,8 @@ def prompt_text(description, init_text = "", true_text="OK", false_text="Back",
89
89
edit .set_focus ()
90
90
ugfx .flush ()
91
91
92
- wait_for_interupt = True
93
- while wait_for_interupt :
92
+ wait_for_interrupt = True
93
+ while wait_for_interrupt :
94
94
#if buttons.is_triggered("BTN_A"): return edit.text()
95
95
if buttons .is_triggered ("BTN_B" ): return None
96
96
if buttons .is_triggered ("BTN_MENU" ): return edit .text ()
@@ -111,7 +111,7 @@ def prompt_option(options, index=0, text = "Please select one of the following:"
111
111
If none_text is specified the user can use the B or Menu button to skip the selection
112
112
if title is specified a blue title will be displayed about the text
113
113
"""
114
- global wait_for_interupt
114
+ global wait_for_interrupt
115
115
116
116
ugfx .set_default_font ("Roboto_Regular12" )
117
117
window = ugfx .Container (5 , 5 , ugfx .width () - 10 , ugfx .height () - 10 )
@@ -145,8 +145,8 @@ def prompt_option(options, index=0, text = "Please select one of the following:"
145
145
try :
146
146
ugfx .input_init ()
147
147
148
- wait_for_interupt = True
149
- while wait_for_interupt :
148
+ wait_for_interrupt = True
149
+ while wait_for_interrupt :
150
150
if buttons .is_triggered ("BTN_A" ): return options [options_list .selected_index ()]
151
151
if button_none and buttons .is_triggered ("BTN_B" ): return None
152
152
if button_none and buttons .is_triggered ("BTN_MENU" ): return None
@@ -159,6 +159,14 @@ def prompt_option(options, index=0, text = "Please select one of the following:"
159
159
if button_none : button_none .destroy ()
160
160
ugfx .poll ()
161
161
162
+
163
+ def do_interrupt (pushed ):
164
+ global wait_for_interrupt
165
+ wait_for_interrupt = False
166
+
167
+ ugfx .input_attach (ugfx .BTN_A , do_interrupt )
168
+ ugfx .input_attach (ugfx .BTN_B , do_interrupt )
169
+
162
170
class WaitingMessage :
163
171
"""Shows a dialog with a certain message that can not be dismissed by the user"""
164
172
def __init__ (self , text = "Please Wait..." , title = "SHA2017Badge" ):
@@ -191,6 +199,3 @@ def __enter__(self):
191
199
192
200
def __exit__ (self , exc_type , exc_value , traceback ):
193
201
self .destroy ()
194
-
195
- ugfx .input_attach (ugfx .BTN_A , wait_for_interupt = False )
196
- ugfx .input_attach (ugfx .BTN_B , wait_for_interupt = False )
0 commit comments