def _do_analyze_sgf_popup(self): if not self.fileselect_popup: popup_contents = LoadSGFPopup() popup_contents.filesel.path = os.path.abspath( os.path.expanduser(self.config("general/sgf_load", "."))) self.fileselect_popup = I18NPopup(title_key="load sgf title", size=[dp(1200), dp(800)], content=popup_contents).__self__ def readfile(*_args): files = popup_contents.filesel.selection self.fileselect_popup.dismiss() path, file = os.path.split(files[0]) settings_path = self.config("general/sgf_load") if path != settings_path: self.log(f"Updating sgf load path default to {path}", OUTPUT_INFO) self._config["general"]["sgf_load"] = path self.save_config("general") try: move_tree = KaTrainSGF.parse_file(files[0]) except ParseError as e: self.log( i18n._("Failed to load SGF").format(error=e), OUTPUT_ERROR) return self._do_new_game(move_tree=move_tree, analyze_fast=popup_contents.fast.active) if not popup_contents.rewind.active: self.game.redo(999) popup_contents.filesel.on_success = readfile popup_contents.filesel.on_submit = readfile self.fileselect_popup.open()
def _do_analyze_sgf_popup(self): if not self.fileselect_popup: popup_contents = LoadSGFPopup(self) popup_contents.filesel.path = os.path.abspath( os.path.expanduser(self.config("general/sgf_load", "."))) self.fileselect_popup = I18NPopup(title_key="load sgf title", size=[dp(1200), dp(800)], content=popup_contents).__self__ def readfile(*_args): filename = popup_contents.filesel.filename self.fileselect_popup.dismiss() path, file = os.path.split(filename) if path != self.config("general/sgf_load"): self.log(f"Updating sgf load path default to {path}", OUTPUT_DEBUG) self._config["general"]["sgf_load"] = path popup_contents.update_config(False) self.save_config("general") self.load_sgf_file(filename, popup_contents.fast.active, popup_contents.rewind.active) popup_contents.filesel.on_success = readfile popup_contents.filesel.on_submit = readfile self.fileselect_popup.open() self.fileselect_popup.content.filesel.ids.list_view._trigger_update()
def _do_analyze_sgf_popup(self): if not self.fileselect_popup: popup_contents = LoadSGFPopup() popup_contents.filesel.path = os.path.abspath( os.path.expanduser(self.config("general/sgf_load", "."))) self.fileselect_popup = I18NPopup(title_key="load sgf title", size=[1200, 800], content=popup_contents).__self__ def readfile(*args): files = popup_contents.filesel.selection self.fileselect_popup.dismiss() try: move_tree = KaTrainSGF.parse_file(files[0]) except ParseError as e: self.log( i18n._("Failed to load SGF").format(error=e), OUTPUT_ERROR) return self._do_new_game(move_tree=move_tree, analyze_fast=popup_contents.fast.active) if not popup_contents.rewind.active: self.game.redo(999) popup_contents.filesel.on_success = readfile popup_contents.filesel.on_submit = readfile self.fileselect_popup.open()