def run(self): times = self.history.keys() times.sort() start_time = time.clock() elapsed_time = 0.0 keyboard.show() for t in times: force_exit_event.wait(t-elapsed_time) if force_exit_event.isSet(): break event = self.history[t] import pygame_run pygame_run.post_tutorial_event(self, event) elapsed_time = time.clock() - start_time # end for # At this point, either we've been told by the main Archy thread that we need to quit (meaning that the user has probably pressed a key in the middle of the tutorial), or we've run out of events to dispatch. If the latter is the case, then we need to wait around for the main Archy thread to tell us to quit. force_exit_event.wait() # At this point, our thread has exclusive control of Archy's state, since the main Archy thread is waiting for the force_exit_event event to be cleared. Therefore, we must be certain to clear this event at the *very end* of this function, and no sooner--lest we give up our exclusive control of Archy's state and throw thread safety out the window. keyboard.hide() self.doOnDone() commands.save_and_load.saveState() is_running_event.clear() force_exit_event.clear()
def prompt_text(description, init_text="", true_text="OK", false_text="Back", width=300, height=200, font="Roboto_BlackItalic24", cb=None): keyboard.show(description, init_text, cb)
def connectClick(pushed): global chosenSsid if pushed: selected = options.selected_text().encode() ssidType = scanResults[ssidList.index(selected)][4] if ssidType == 5: easydraw.messageCentered("WPA Enterprise is not supported yet.", True, "/media/alert.png") system.reboot() chosenSsid = selected if ssidType == 0: passInputDone(None) else: keyboard.show("Password","",passInputDone)
def doKey(self, keystroke, event): keyboard.show(keystroke) if type(keystroke) == int: keyValue = keystroke keystroke = '' else: keyValue = ord(keystroke) if event == "press": is_upper = archy_globals.apply_shift_key_to_character( keystroke) == keystroke if is_upper: archyState.keyState.right_shift = 'down' self.sound.stop() self.sound.play() if keyboard.isModifier(keyValue): keyboard.addModifier(keyValue) archyState.keyState.keypress(keyValue, keystroke, "down") archyState.keyState.keypress(keyValue, keystroke, "up") if is_upper: archyState.keyState.right_shift = 'up' elif event == "_unpress": keyboard.show('') if keyboard.isModifier(keyValue): keyboard.unshowLeap() elif event == "show": keyboard.addModifier(keyValue) elif event == "unshow": keyboard.removeModifier(keyValue) elif event == "down" or event == "up": archyState.keyState.keypress(keyValue, keystroke, event) if event == "down": keyboard.addModifier(keyValue) self.sound.stop() self.sound.play() if event == "up": keyboard.removeModifier(keyValue)
def doKey(self, keystroke, event): keyboard.show(keystroke) if type(keystroke) == int: keyValue = keystroke keystroke = '' else: keyValue = ord(keystroke) if event == "press": is_upper = archy_globals.apply_shift_key_to_character(keystroke) == keystroke if is_upper: archyState.keyState.right_shift = 'down' self.sound.stop() self.sound.play() if keyboard.isModifier(keyValue): keyboard.addModifier(keyValue) archyState.keyState.keypress(keyValue, keystroke, "down") archyState.keyState.keypress(keyValue, keystroke, "up") if is_upper: archyState.keyState.right_shift = 'up' elif event == "_unpress": keyboard.show('') if keyboard.isModifier(keyValue): keyboard.unshowLeap() elif event == "show": keyboard.addModifier(keyValue) elif event == "unshow": keyboard.removeModifier(keyValue) elif event == "down" or event == "up": archyState.keyState.keypress(keyValue, keystroke, event) if event == "down": keyboard.addModifier(keyValue) self.sound.stop() self.sound.play() if event == "up": keyboard.removeModifier(keyValue)
def run(self): times = self.history.keys() times.sort() start_time = time.clock() elapsed_time = 0.0 keyboard.show() for t in times: force_exit_event.wait(t - elapsed_time) if force_exit_event.isSet(): break event = self.history[t] import pygame_run pygame_run.post_tutorial_event(self, event) elapsed_time = time.clock() - start_time # end for # At this point, either we've been told by the main Archy thread that we need to quit (meaning that the user has probably pressed a key in the middle of the tutorial), or we've run out of events to dispatch. If the latter is the case, then we need to wait around for the main Archy thread to tell us to quit. force_exit_event.wait() # At this point, our thread has exclusive control of Archy's state, since the main Archy thread is waiting for the force_exit_event event to be cleared. Therefore, we must be certain to clear this event at the *very end* of this function, and no sooner--lest we give up our exclusive control of Archy's state and throw thread safety out the window. keyboard.hide() self.doOnDone() commands.save_and_load.saveState() is_running_event.clear() force_exit_event.clear()
import system, badge, keyboard def callback(value): if value: badge.nvs_set_str("owner", "name", value) system.home() nickname = badge.nvs_get_str("owner", "name", "") keyboard.show("Nickname", nickname, callback)