fix popup/path bugs

This commit is contained in:
Sander Land committed 2021-01-03 09:59:44 +01:00
1 parent d80c5692d0
commit 5974bfb783
5 files changed
+17 -5

No files matched your search

+7 -1
View File
@@ -292,7 +292,13 @@ class KaTrainGui(Screen, KaTrainBase):
self.play_mode.switch_ui_mode() # for new game, go to play, for loaded, analyze
self.board_gui.animating_pv = None
self.engine.on_new_game() # clear queries
self.game = Game(self, self.engine, move_tree=move_tree, analyze_fast=analyze_fast or not move_tree, sgf_filename=sgf_filename)
self.game = Game(
self,
self.engine,
move_tree=move_tree,
analyze_fast=analyze_fast or not move_tree,
sgf_filename=sgf_filename,
)
if move_tree:
for bw, player_info in self.players_info.items():
player_info.player_type = PLAYER_HUMAN
+1
View File
@@ -45,6 +45,7 @@ class KataGoEngine:
self.stderr_thread = None
self.write_stdin_thread = None
self.shell = False
self.write_queue = queue.Queue()
exe = config.get("katago", "").strip()
if config.get("altcommand", ""):
+1 -1
View File
@@ -409,7 +409,7 @@ class SGF:
if match:
encoding = match[1].decode("ascii", errors="ignore")
else:
encoding = chardet.detect(bin_contents[:300])['encoding']
encoding = chardet.detect(bin_contents[:300])["encoding"]
# workaround for some compatibility issues for Windows-1252 and GB2312 encodings
if encoding == "Windows-1252" or encoding == "GB2312":
encoding = "GBK"
+7 -3
View File
@@ -44,8 +44,10 @@ class I18NPopup(Popup):
title_key = StringProperty("")
font_name = StringProperty(Theme.DEFAULT_FONT)
def __init__(self, **kwargs):
super().__init__(**kwargs)
def __init__(self, size=None, **kwargs):
if size: # do not exceed window height
size[1] = min(MDApp.get_running_app().gui.height, size[1])
super().__init__(size=size, **kwargs)
self.bind(on_dismiss=Clock.schedule_once(lambda _dt: MDApp.get_running_app().gui.update_state(), 1))
@@ -63,13 +65,15 @@ class LabelledTextInput(MDTextField):
class LabelledPathInput(LabelledTextInput):
check_path = BooleanProperty(True)
def __init__(self, **kwargs):
super().__init__(**kwargs)
Clock.schedule_once(self.check_error, 0)
def check_error(self, _dt=None):
file = find_package_resource(self.input_value, silent_errors=True)
self.error = not (file and os.path.exists(file))
self.error = self.check_path and not (file and os.path.exists(file))
def on_text(self, widget, text):
self.check_error()
+1
View File
@@ -160,6 +160,7 @@
size_hint: 0.33, 1
AnchorLayout:
LabelledPathInput:
check_path: False
input_property: "engine/altcommand"
hint_text: i18n._("engine:altcommand:hint")
BoxLayout: