From b749bdd807f60fd106aab0c2ee278464f36fcaab Mon Sep 17 00:00:00 2001 From: yw1573 Date: Tue, 28 Jul 2026 10:26:48 +0800 Subject: [PATCH] =?UTF-8?q?fix(gui,gcode):=20=E6=97=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=97=B6=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=98=BE=E7=A4=BA0s?= =?UTF-8?q?=E5=92=8C0.00g=E6=9B=BF=E4=BB=A3=E6=9C=AA=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit format_duration/format_filament 接收 None 时返回零值字符串而非未知, GUI 初始合计标签同步更新。 --- a1_swap_mod_packer/gcode.py | 4 ++-- a1_swap_mod_packer/gui.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/a1_swap_mod_packer/gcode.py b/a1_swap_mod_packer/gcode.py index bd13c23..b435ae6 100644 --- a/a1_swap_mod_packer/gcode.py +++ b/a1_swap_mod_packer/gcode.py @@ -120,7 +120,7 @@ def format_duration(seconds: float | None) -> str: 格式化后的时间字符串,如 "2h 30m"、"5m 20s"、"45s",未知则返回 "未知"。 """ if seconds is None: - return "未知" + return "0s" total = max(0, int(round(seconds))) hours, rem = divmod(total, 3600) minutes, secs = divmod(rem, 60) @@ -142,7 +142,7 @@ def format_filament(weight_grams: float | None, used_m: float | None = None) -> 格式化后的耗材信息字符串,未知则返回 "未知"。 """ if weight_grams is None and used_m is None: - return "未知" + return "0.00 g" parts: list[str] = [] if weight_grams is not None: parts.append(f"{weight_grams:.2f} g") diff --git a/a1_swap_mod_packer/gui.py b/a1_swap_mod_packer/gui.py index 071a313..67cfdde 100644 --- a/a1_swap_mod_packer/gui.py +++ b/a1_swap_mod_packer/gui.py @@ -423,7 +423,7 @@ class MainWindow(QMainWindow): table_layout.addWidget(self.table) # --- 合计统计标签 --- - self.total_summary_label = QLabel("合计:0 板 | 时间:未知 | 耗材:未知") + self.total_summary_label = QLabel("合计:0 板 | 时间:0s | 耗材:0.00 g") table_layout.addWidget(self.total_summary_label) file_body.addLayout(table_layout, 1)