def _cancel(): raise StopApplication('User pressed cancel')
def _ok(): raise StopApplication("Continue")
def _quit_on_yes(selected): if selected == 1: # second button raise StopApplication("Normal termination")
def _quit(): raise StopApplication("User pressed quit")
def _quit_on_yes(selected): # Yes is the first button if selected == 0: raise StopApplication("User requested exit")
def _quit(self): print("Bye!") raise StopApplication("User pressed quit")
def play( self, stop_on_resize=False, unhandled_input=None, start_scene=None, repeat=True, allow_int=False, ): self.reset = [Slide(self, _reset(self.screen), 7, 0)] self.slides = [ Slide(self, self.get_effects(slide), slide.fg_color, slide.bg_color) for slide in self.slides ] # Initialise the Screen for animation. self.screen.set_scenes(self.slides, unhandled_input=unhandled_input, start_scene=start_scene) self.screen.clear_buffer(self.slides[0].fg_color, 0, self.slides[0].bg_color) # Mainline loop for animations try: while True: if self.current_slide == len(self.slides): self.screen.set_scenes(self.reset) while True: a = time.time() self.screen.draw_next_frame(repeat=repeat) b = time.time() if b - a < 0.05: # Just in case time has jumped (e.g. time change), ensure we only delay for 0.05s pause = min(0.05, a + 0.05 - b) if allow_int: self.screen.wait_for_input(pause) else: time.sleep(pause) event = self.screen.get_event() if isinstance(event, KeyboardEvent): if event.key_code == ord("r"): self.current_slide = 0 self.screen.set_scenes( [self.slides[self.current_slide]]) self.screen.clear_buffer( self.slides[self.current_slide].fg_color, 0, self.slides[self.current_slide].bg_color, ) break else: raise StopApplication("Stop slideshow") a = time.time() self.screen.draw_next_frame(repeat=repeat) if self.screen.has_resized(): if stop_on_resize: self.screen._scenes[self.screen._scene_index].exit() raise ResizeScreenError( "Screen resized", self.screen._scenes[self.screen._scene_index], ) b = time.time() if b - a < 0.05: # Just in case time has jumped (e.g. time change), ensure we only delay for 0.05s pause = min(0.05, a + 0.05 - b) if allow_int: self.screen.wait_for_input(pause) else: time.sleep(pause) except StopApplication: # Time to stop - just exit the function. self.screen.clear() return
def _next_button_click(self): self.save() self._frame_data.controls_data = self.data self._frame_data.forward = True raise StopApplication("Exit on Next button click")
def _on_click_quit(self): raise StopApplication("User quit")
def _cancel_button_click(self): self._frame_data.cancelled = True raise StopApplication("Exit on Cancel button click")
def _back_button_click(self): if self._back_enabled: self.save() self._frame_data.controls_data = self.data self._frame_data.forward = False raise StopApplication("Exit on Back button click")
def _quit(self): shutil.rmtree('img') os.mkdir('img') raise StopApplication("User requested exit")
def process_event(self, event): # Do the key handling for this Frame. if isinstance(event, KeyboardEvent): if event.key_code in [ord('q'), ord('Q'), Screen.ctrl("c")]: raise StopApplication("User quit") self.swichWindow(self.presenter, event) if event.key_code in [ord('e')]: self.presenter.mainPlaylistSetPlayId(self.table.value) self.presenter.playerPlayById(self.table.value) if event.key_code in [ord('j')]: #swap _from = self.table._line _to = self.table._line - 1 if self.table._line > 0 else self.table._line self.presenter.playerSwap(_from, _to) self.table._line = max(0, self.table._line - 1) self.table.value = self.table._options[self.table._line][1] if event.key_code in [ord('k')]: #swap _from = self.table._line _to = self.table._line + 1 if self.table._line < len( self.table._options) - 1 else self.table._line self.presenter.playerSwap(_from, _to) self.table._line = min( len(self.table._options) - 1, self.table._line + 1) self.table.value = self.table._options[self.table._line][1] if event.key_code in [ord('d')]: #delete _id = self.table._line self.presenter.playerDelete(_id) if len(self.table._options) > 0: self.table._line = min( len(self.table._options) - 1, self.table._line + 1) self.table.value = self.table._options[self.table._line][1] _new_options = [] for i, e in enumerate(self.table._options): v = e[0] v[0] = str(i) _new_options.append((v, i)) self.table._options = _new_options if event.key_code in [ord('E')]: pls = self.presenter.getListOfPlaylists() for i, e in enumerate(pls): pls[i] = (e, i) self._scene.add_effect( AddMusicDialog(self._screen, "Save playlist", ["OK", "Cancel"], addList=[("At the end of playlist", ADD_END), ("At the beginning of playlist", ADD_BEGIN)], playlistLists=pls, needNewPlaylist=True, needListAdd=True, needListPlaylists=True, needPlayCb=False, presenter=self.presenter, win="MainPlaylist")) if event.key_code in [ord("i")]: self._scene.add_effect( InfoDialog(self._screen, "Info", ["OK"], config=self.presenter.config, win=self.frameName)) self.presenter.playerEventControl(event) # Now pass on to lower levels for normal handling of the event. return super(MainPlaylistFrame, self).process_event(event)
def _quit(self): self.timer_obj.proc.cancel() self.cancel_future_calls() raise StopApplication("User Pressed Quit")
def _save_config_and_exit(self): self._save_config() raise StopApplication("User requested exit")
def _menu(): SCREEN.menu_flag = True raise StopApplication("User terminated app")
def global_shortcuts(event): if isinstance(event, KeyboardEvent): c = event.key_code if c in (17, 24): raise StopApplication("User terminated app")
def _quit(): SCREEN.set_exit() raise StopApplication("User pressed quit")
def _quit(self): self.save() print("Bye!") print(self.data) raise StopApplication("User pressed quit")
def cancel_click(): raise StopApplication('Quit')
def _quit(self): if self._model._player and self._model._player.isAlive(): self._model.terminate() raise StopApplication("User pressed quit")
def logout_click(): raise StopApplication('Logout')
def _quit(self): raise StopApplication("User requested exit")
def _submit(self): for key, value in self.data.items(): input_payload[key]["value"] = str(value) raise StopApplication("User requested exit")
def _quit_on_yes(selected: int) -> typing.NoReturn: if selected == 0: raise StopApplication("User pressed quit")
def _pass(self): confirm_payload["confirm_answer"] = "SUCCESS" raise StopApplication("User requested exit")
def stop_wizard(_): raise StopApplication('')
def _fail(self): confirm_payload["confirm_answer"] = "FAILURE" raise StopApplication("User requested exit")
def _quit(self): raise StopApplication("User stopped application")
def _quit_on_yes(selected): # Yes is the first button if selected == 0: raise StopApplication("Spiel beendet")