def run(self): if len(sys.argv) > 1: path = os.path.abspath(sys.argv[1]) self.core.load_exercise(path) elif config.get("lastopenfile"): self.logger.info("last open file : " + config.get("lastopenfile")) self.core.load_exercise(config.get("lastopenfile")) self.gui.run()
def toggle_lateral_panel(self): if config.get("showlateralpanel"): self.gui.set_visible_lateral_panel(False) config.set("showlateralpanel", 0) else: self.gui.set_visible_lateral_panel(True) config.set("showlateralpanel", 1)
def notify_quit(self): if not config.get("autosave"): if not self.core.get_can_save(): self.gui.quit() return False #True for quit elif self.gui.ask_confirm_quit_without_save(): config.save() self.gui.quit() return False #True for quit else: return True #True for not quit else: self.core.save() config.save() self.gui.quit() return True #True for quit
def notify_quit(self): if not config.get("autosave"): if not self.core.get_can_save(): self.gui.quit() return False # True for quit elif self.gui.ask_confirm_quit_without_save(): config.save() self.gui.quit() return False # True for quit else: return True # True for not quit else: self.core.save() config.save() self.gui.quit() return True # True for quit
def __init__(self): """GuiController constructor""" self.core = None self.word_list = None # Mode can be closed, loaded or load_failed self.mode = "closed" self.gui = Gui(self) self.gui.set_active_video_area(False) self.gui_exercise_controller = None self.translation_visible = False self.correction_visible = False self.current_speed = 1.0 if not config.get("showlateralpanel"): self.gui.set_visible_lateral_panel(False) else: self.gui.set_checked_lateral_panel(True) self.gui.set_visible_lateral_panel(True) config.set("showlateralpanel", 1)
def refresh(self): "Enable or disable ihm component" if self.mode == "loaded": self.gui.set_enable_sequence_index_selection(True) self.gui.set_enable_sequence_time_selection(True) self.gui.set_enable_replay_sequence(True) self.gui.set_enable_save_as(True) self.gui.set_enable_save(True) self.gui.set_enable_export_as_template(True) self.gui.set_enable_export_as_package(True) if self.core.get_exercise().is_lock_correction( ) and not self.core.get_exercise().is_lock_correction_password(): self.gui.set_enable_correction(False) else: self.gui.set_enable_correction(True) if self.core.get_exercise().is_lock_properties( ) and not self.core.get_exercise().is_lock_properties_password(): self.gui.set_enable_properties(False) self.gui.set_enable_advanced_properties(False) else: self.gui.set_enable_properties(True) self.gui.set_enable_advanced_properties(True) #Help if self.core.get_exercise().is_lock_help(): self.gui.set_enable_hint(False) self.gui.set_enable_reveal_word(False) self.gui.set_enable_reveal_sequence(False) self.gui.set_enable_translation(False) else: self.gui.set_enable_hint(True) self.gui.set_enable_reveal_word(True) self.gui.set_enable_reveal_sequence(True) self.gui.set_enable_translation(True) #Disable speed change slider if the media player not support it if config.get( "interface_use_speed_change" ) == 1 and self.core.get_player().is_speed_changeable( ) and not self.core.get_exercise().is_lock_help(): self.gui.set_enable_speed_selection(True) else: self.gui.set_enable_speed_selection(False) if self.mode == "load_failed": self.gui.set_enable_sequence_index_selection(False) self.gui.set_enable_sequence_time_selection(False) self.gui.set_enable_hint(False) self.gui.set_enable_reveal_word(False) self.gui.set_enable_reveal_sequence(False) self.gui.set_enable_replay_sequence(False) self.gui.set_enable_properties(True) self.gui.set_enable_advanced_properties(True) self.gui.set_enable_translation(False) self.gui.set_enable_save_as(False) self.gui.set_enable_save(False) self.gui.set_enable_export_as_template(False) self.gui.set_enable_export_as_package(False) self.gui.set_enable_speed_selection(False) self.gui.set_enable_correction(False) if self.mode == "closed": self.gui.set_enable_sequence_index_selection(False) self.gui.set_enable_sequence_time_selection(False) self.gui.set_enable_hint(False) self.gui.set_enable_reveal_word(False) self.gui.set_enable_reveal_sequence(False) self.gui.set_enable_replay_sequence(False) self.gui.set_enable_properties(False) self.gui.set_enable_advanced_properties(False) self.gui.set_enable_translation(False) self.gui.set_enable_save_as(False) self.gui.set_enable_save(False) self.gui.set_enable_export_as_template(False) self.gui.set_enable_export_as_package(False) self.gui.set_enable_speed_selection(False) self.gui.set_enable_correction(False) if config.get("interface_show_play_pause_buttons") == 1: self.gui.set_visible_play(True) self.gui.set_visible_pause(True) else: self.gui.set_visible_play(False) self.gui.set_visible_pause(False) if config.get("interface_lock_settings") != 1: self.gui.set_enable_settings(True) else: self.gui.set_enable_settings(False)
def notify_previous_sequence(self): if config.get("navigation_skip_valid_sequences") == 0: self.core.previous_sequence() else: self.core.previous_valid_sequence()
def notify_next_sequence(self): if config.get("navigation_skip_valid_sequences") == 0: self.core.next_sequence() else: self.core.next_valid_sequence()
def refresh(self): "Enable or disable ihm component" if self.mode == "loaded": self.gui.set_enable_sequence_index_selection(True) self.gui.set_enable_sequence_time_selection(True) self.gui.set_enable_replay_sequence(True) self.gui.set_enable_save_as(True) self.gui.set_enable_save(True) self.gui.set_enable_export_as_template(True) self.gui.set_enable_export_as_package(True) if ( self.core.get_exercise().is_lock_correction() and not self.core.get_exercise().is_lock_correction_password() ): self.gui.set_enable_correction(False) else: self.gui.set_enable_correction(True) if ( self.core.get_exercise().is_lock_properties() and not self.core.get_exercise().is_lock_properties_password() ): self.gui.set_enable_properties(False) self.gui.set_enable_advanced_properties(False) else: self.gui.set_enable_properties(True) self.gui.set_enable_advanced_properties(True) # Help if self.core.get_exercise().is_lock_help(): self.gui.set_enable_hint(False) self.gui.set_enable_reveal_word(False) self.gui.set_enable_reveal_sequence(False) self.gui.set_enable_translation(False) else: self.gui.set_enable_hint(True) self.gui.set_enable_reveal_word(True) self.gui.set_enable_reveal_sequence(True) self.gui.set_enable_translation(True) # Disable speed change slider if the media player not support it if ( config.get("interface_use_speed_change") == 1 and self.core.get_player().is_speed_changeable() and not self.core.get_exercise().is_lock_help() ): self.gui.set_enable_speed_selection(True) else: self.gui.set_enable_speed_selection(False) if self.mode == "load_failed": self.gui.set_enable_sequence_index_selection(False) self.gui.set_enable_sequence_time_selection(False) self.gui.set_enable_hint(False) self.gui.set_enable_reveal_word(False) self.gui.set_enable_reveal_sequence(False) self.gui.set_enable_replay_sequence(False) self.gui.set_enable_properties(True) self.gui.set_enable_advanced_properties(True) self.gui.set_enable_translation(False) self.gui.set_enable_save_as(False) self.gui.set_enable_save(False) self.gui.set_enable_export_as_template(False) self.gui.set_enable_export_as_package(False) self.gui.set_enable_speed_selection(False) self.gui.set_enable_correction(False) if self.mode == "closed": self.gui.set_enable_sequence_index_selection(False) self.gui.set_enable_sequence_time_selection(False) self.gui.set_enable_hint(False) self.gui.set_enable_reveal_word(False) self.gui.set_enable_reveal_sequence(False) self.gui.set_enable_replay_sequence(False) self.gui.set_enable_properties(False) self.gui.set_enable_advanced_properties(False) self.gui.set_enable_translation(False) self.gui.set_enable_save_as(False) self.gui.set_enable_save(False) self.gui.set_enable_export_as_template(False) self.gui.set_enable_export_as_package(False) self.gui.set_enable_speed_selection(False) self.gui.set_enable_correction(False) if config.get("interface_show_play_pause_buttons") == 1: self.gui.set_visible_play(True) self.gui.set_visible_pause(True) else: self.gui.set_visible_play(False) self.gui.set_visible_pause(False) if config.get("interface_lock_settings") != 1: self.gui.set_enable_settings(True) else: self.gui.set_enable_settings(False)