From ce3808b94898efa7aea73f8060175ea8b8544d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Sat, 20 Jul 2024 23:38:08 +0800 Subject: [PATCH] . --- .../LunaTranslator/gui/inputdialog.py | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/LunaTranslator/LunaTranslator/gui/inputdialog.py b/LunaTranslator/LunaTranslator/gui/inputdialog.py index 6a2fc924..8529c4b0 100644 --- a/LunaTranslator/LunaTranslator/gui/inputdialog.py +++ b/LunaTranslator/LunaTranslator/gui/inputdialog.py @@ -425,7 +425,21 @@ class autoinitdialog(LDialog): self.setWindowTitle(title) self.resize(QSize(width, 10)) - formLayout = None + for line in lines: + if line["type"] != "program": + continue + try: + func = getattr( + importlib.import_module(line["route"][0]), + line["route"][1], + ) + func(self) + except: + print_exc() + self.show() + return + formLayout = LFormLayout() + self.setLayout(formLayout) regist = [] def save(callback=None): @@ -472,16 +486,6 @@ class autoinitdialog(LDialog): regist.append([dd, key, functools.partial(__getv, __list)]) lineW = QHBoxLayout() lineW.addWidget(e) - elif line["type"] == "program": - try: - func = getattr( - importlib.import_module(line["route"][0]), - line["route"][1], - ) - func(self) - except: - print_exc() - break elif line["type"] == "combo": lineW = LFocusCombo() if "list_function" in line: @@ -564,9 +568,6 @@ class autoinitdialog(LDialog): lineW.setFixedHeight(2) formLayout.addRow(lineW) continue - if formLayout is None: - formLayout = LFormLayout() - self.setLayout(formLayout) refswitch = line.get("refswitch", None) if refswitch: hbox = QHBoxLayout()