codex/windows-native-pilot-shell-20261030
add-index-html-10623938925177053894
arena/094f314c-aram
chatgpt-phase1b2-autopilot
codex/adr-future-connectors-pi-v1
codex/aram-account-note-source-trace-20261031
codex/aram-actions-node24-maintenance-20261031
codex/aram-analyst-review-workbook-20261031
codex/aram-bs-candidate-statement-20261031
codex/aram-cash-flow-direct-candidate-20261031
codex/aram-clean-reference-year-integrity-20261030
codex/aram-cross-statement-controls-20261031
codex/aram-equity-changes-candidate-20261031
codex/aram-five-statement-cli-20261031
codex/aram-five-statement-integration-20261031
codex/aram-five-statement-orchestrator-20261031
codex/aram-gate3-coverage-target-guard-20261030
codex/aram-gate3-hidden-xlsx-guard-20261030
codex/aram-gate3-integration-validation-20261030
codex/aram-gate3-mapping-change-preview-20261030
codex/aram-gate3-stale-note-guard-20261030
codex/aram-income-statement-candidate-20261031
codex/aram-manifest-referential-integrity-20261031
codex/aram-mapping-source-parser-20261101
codex/aram-multidimensional-mapping-20261101
codex/aram-multistatement-mapping-20261031
codex/aram-pipeline-manifest-schema-20261031
codex/aram-readonly-mapping-coverage-20261031
codex/aram-reconciliation-review-gate-20261031
codex/aram-same-flush-fiscal-lock-20261030
codex/aram-synthetic-windows-demo-20261031
codex/aram-trial-balance-diagnostic-20261031
codex/aram-windows-background-detail-search-20261031
codex/aram-windows-detail-review-20261031
codex/aram-windows-five-statement-pilot-20261031
codex/aram-windows-statement-figures-20261031
codex/gate-2a-pilot-workbook
codex/gate-2a-pilot-workbook-6864754244772568979
codex/gate3-authenticated-principal-boundary-20261030
codex/gate3-authored-draft-staging-20261030
codex/gate3-carry-forward-preview-20261023
codex/gate3-draft-staging-audit-20261030
codex/gate3-mapping-batch-freshness-20261030
codex/gate3-mapping-batch-review-20261030
codex/gate3-mapping-core
codex/gate3-mapping-coverage-20261023
codex/gate3-mapping-excel-20261023
codex/gate3-note-mapping-review-20261023
codex/gate3-signed-year-scope-20261030
codex/gate3-unapproved-proposal-storage-20261030
codex/payvast-mapping-discovery-20261023
codex/phase-2a-backend-foundation
codex/phase-2b-post-merge-record
codex/phase-2b-source-registration
codex/phase-2b-source-registration-12955190277775369594
codex/post-gate2a-control-reconciliation
codex/post-pr18-acceptance-record
codex/project-control-foundation
codex/t1-repo-hygiene-20261023
codex/t2-ci-hardening-20261023
codex/t3-explicit-migrations-20261023
codex/t6a-readonly-diagnostics-20261023
codex/v1-01-safety-gate-hardening
codex/v1-year-isolation-followup-20261023
codex/windows-native-pilot-shell-20261030
docs/aram-master-control-plan-20261111
docs/aram-roadmap-dashboard-20261030
docs/financial-statement-reconciliation-1402-1404-20261110
feat/gate3-governed-mapping-20261101
feat/gate3-package9-1-security-20261103
feat/gate3-package9-isolated-20261103
fix/password-unicode-validation-20261111
governance/aram-5-1-3-controls-20261030
governance/role-based-operating-model
jules-1168663913887856558-73b8a885
jules-gate-2b-mapping-workflow-foundation-4137724387867065330
phase-1b1-audit-report-7365389436990903239
phase-2a-backend-foundation-10237597358138521261
phase1b2-postmerge-metadata-fix
refactor/drg-parent-year-id-15088443704684163304
source-data-cleanup
| 1 | """Native Tk/ttk Windows Pilot UI: read-only XLSX validation, no posting. |
| 2 | |
| 3 | The current program is NOT the final financial statements product. Unbuilt |
| 4 | workflows are textual blockers, never decorative clickable dead buttons. |
| 5 | """ |
| 6 | from __future__ import annotations |
| 7 | |
| 8 | import sys |
| 9 | import tempfile |
| 10 | import tkinter as tk |
| 11 | from pathlib import Path |
| 12 | from tkinter import filedialog, messagebox, ttk |
| 13 | from typing import Callable |
| 14 | |
| 15 | from aram_backend.desktop_pilot_core import DesktopPilotController, PilotInputError |
| 16 | from aram_backend.pilot_workbook import SHEET_HEADERS, preflight_pilot_workbook |
| 17 | |
| 18 | APP_TITLE = "آرام | پایلوت دسکتاپ — آزمایشی و فاقد مجوز صدور صورت مالی" |
| 19 | PILOT_ACTIONS = { |
| 20 | "file.open": "open_workbook", |
| 21 | "file.validate": "validate_workbook", |
| 22 | "file.clear": "clear_workbook", |
| 23 | "file.exit": "exit_application", |
| 24 | "help.about": "show_about", |
| 25 | } |
| 26 | MAX_VISIBLE_ISSUES = 3000 |
| 27 | |
| 28 | |
| 29 | class PilotWindow(tk.Tk): |
| 30 | """Real native desktop controls; all enabled actions have callbacks.""" |
| 31 | |
| 32 | def __init__( |
| 33 | self, *, |
| 34 | file_picker: Callable[[], str] | None = None, |
| 35 | info_dialog: Callable[[str, str], None] | None = None, |
| 36 | ) -> None: |
| 37 | super().__init__() |
| 38 | self.controller = DesktopPilotController() |
| 39 | self._file_picker = file_picker or ( |
| 40 | lambda: filedialog.askopenfilename( |
| 41 | parent=self, title="انتخاب فایل اکسل پایلوت آرام", |
| 42 | filetypes=[("Pilot workbook", "*.xlsx")], |
| 43 | ) |
| 44 | ) |
| 45 | self._info_dialog = info_dialog or ( |
| 46 | lambda title, text: messagebox.showinfo(title, text, parent=self) |
| 47 | ) |
| 48 | self.title(APP_TITLE) |
| 49 | self.geometry("1080x710") |
| 50 | self.minsize(820, 560) |
| 51 | self.configure(bg="#edf2f7") |
| 52 | self.file_name = tk.StringVar(value="فایلی انتخاب نشده است.") |
| 53 | self.summary = tk.StringVar(value="ابتدا یک فایل با قالب پایلوت انتخاب کنید.") |
| 54 | self.status = tk.StringVar(value="حالت ایمن: هیچ دادهای ثبت یا تأیید نمیشود.") |
| 55 | self._set_style() |
| 56 | self._build_menu() |
| 57 | self._build_content() |
| 58 | self._register_keys() |
| 59 | self._refresh_controls() |
| 60 | |
| 61 | def _set_style(self) -> None: |
| 62 | style = ttk.Style(self) |
| 63 | if "clam" in style.theme_names(): |
| 64 | style.theme_use("clam") |
| 65 | style.configure("Pilot.TLabel", font=("Tahoma", 11), background="#edf2f7") |
| 66 | style.configure("PilotTitle.TLabel", font=("Tahoma", 20, "bold"), |
| 67 | background="#edf2f7", foreground="#152e4d") |
| 68 | style.configure("PilotBanner.TLabel", font=("Tahoma", 10, "bold"), |
| 69 | background="#fff0d8", foreground="#78350f", |
| 70 | padding=12) |
| 71 | style.configure("Pilot.TButton", font=("Tahoma", 11), padding=10) |
| 72 | style.configure("Pilot.TNotebook.Tab", font=("Tahoma", 11), padding=(18, 12)) |
| 73 | style.configure("Pilot.Treeview", font=("Tahoma", 10), rowheight=28) |
| 74 | style.configure("Pilot.Treeview.Heading", font=("Tahoma", 10, "bold")) |
| 75 | |
| 76 | def _build_menu(self) -> None: |
| 77 | self._bar = tk.Menu(self) |
| 78 | self.file_menu = tk.Menu(self._bar, tearoff=0) |
| 79 | self.file_menu.add_command( |
| 80 | label="انتخاب فایل اکسل", accelerator="Ctrl+O", |
| 81 | command=self.open_workbook, |
| 82 | ) |
| 83 | self.file_menu.add_command( |
| 84 | label="اجرای پیشبررسی", accelerator="Ctrl+R", |
| 85 | command=self.validate_workbook, |
| 86 | ) |
| 87 | self.file_menu.add_command( |
| 88 | label="پاککردن انتخاب", accelerator="Ctrl+L", |
| 89 | command=self.clear_workbook, |
| 90 | ) |
| 91 | self.file_menu.add_separator() |
| 92 | self.file_menu.add_command( |
| 93 | label="خروج", accelerator="Ctrl+Q", command=self.exit_application, |
| 94 | ) |
| 95 | self._bar.add_cascade(label="فایل", menu=self.file_menu) |
| 96 | self.help_menu = tk.Menu(self._bar, tearoff=0) |
| 97 | self.help_menu.add_command( |
| 98 | label="درباره و محدودیتهای پایلوت", accelerator="F1", |
| 99 | command=self.show_about, |
| 100 | ) |
| 101 | self._bar.add_cascade(label="راهنما", menu=self.help_menu) |
| 102 | self.config(menu=self._bar) |
| 103 | |
| 104 | def _build_content(self) -> None: |
| 105 | outer = ttk.Frame(self, padding=18) |
| 106 | outer.pack(fill="both", expand=True) |
| 107 | ttk.Label(outer, text="آرام — پایلوت کنترل اولیه فایل اکسل", |
| 108 | style="PilotTitle.TLabel", anchor="e").pack(fill="x") |
| 109 | ttk.Label( |
| 110 | outer, |
| 111 | text=( |
| 112 | "نسخه آزمایشی دسکتاپ | فقط خواندن و اعتبارسنجی اولیه | " |
| 113 | "فاقد تهیه، ثبت، تأیید، چاپ یا صدور صورتهای مالی" |
| 114 | ), |
| 115 | style="PilotBanner.TLabel", anchor="e", wraplength=930, |
| 116 | ).pack(fill="x", pady=(14, 18)) |
| 117 | |
| 118 | tabs = ttk.Notebook(outer, style="Pilot.TNotebook") |
| 119 | tabs.pack(fill="both", expand=True) |
| 120 | self.tabs = tabs |
| 121 | |
| 122 | preflight_tab = ttk.Frame(tabs, padding=16) |
| 123 | tabs.add(preflight_tab, text="اعتبارسنجی اکسل") |
| 124 | workflow_tab = ttk.Frame(tabs, padding=24) |
| 125 | tabs.add(workflow_tab, text="مراحل مالی و محدودیتها") |
| 126 | help_tab = ttk.Frame(tabs, padding=24) |
| 127 | tabs.add(help_tab, text="راهنما") |
| 128 | |
| 129 | ttk.Label( |
| 130 | preflight_tab, textvariable=self.file_name, |
| 131 | anchor="e", justify="right", wraplength=850, |
| 132 | font=("Tahoma", 11), |
| 133 | ).pack(fill="x", pady=(0, 12)) |
| 134 | buttons = ttk.Frame(preflight_tab) |
| 135 | buttons.pack(fill="x") |
| 136 | self.open_button = ttk.Button( |
| 137 | buttons, text="انتخاب فایل اکسل", command=self.open_workbook, |
| 138 | style="Pilot.TButton", |
| 139 | ) |
| 140 | self.open_button.pack(side="right", padx=5) |
| 141 | self.validate_button = ttk.Button( |
| 142 | buttons, text="بررسی فایل", command=self.validate_workbook, |
| 143 | style="Pilot.TButton", |
| 144 | ) |
| 145 | self.validate_button.pack(side="right", padx=5) |
| 146 | self.clear_button = ttk.Button( |
| 147 | buttons, text="پاککردن انتخاب", command=self.clear_workbook, |
| 148 | style="Pilot.TButton", |
| 149 | ) |
| 150 | self.clear_button.pack(side="right", padx=5) |
| 151 | |
| 152 | ttk.Label( |
| 153 | preflight_tab, textvariable=self.summary, anchor="e", |
| 154 | font=("Tahoma", 11), |
| 155 | ).pack(fill="x", pady=(16, 12)) |
| 156 | |
| 157 | issue_area = ttk.Frame(preflight_tab) |
| 158 | issue_area.pack(fill="both", expand=True) |
| 159 | columns = ("severity", "code", "sheet", "row", "field", "message") |
| 160 | self.issue_tree = ttk.Treeview( |
| 161 | issue_area, columns=columns, show="headings", style="Pilot.Treeview", |
| 162 | selectmode="browse", |
| 163 | ) |
| 164 | header_labels = { |
| 165 | "severity": "اهمیت", "code": "کد خطا", "sheet": "شیت", |
| 166 | "row": "ردیف", "field": "ستون", "message": "توضیح کنترل", |
| 167 | } |
| 168 | sizes = { |
| 169 | "severity": 75, "code": 170, "sheet": 100, |
| 170 | "row": 70, "field": 145, "message": 400, |
| 171 | } |
| 172 | for column in columns: |
| 173 | self.issue_tree.heading(column, text=header_labels[column]) |
| 174 | self.issue_tree.column( |
| 175 | column, width=sizes[column], |
| 176 | minwidth=65, anchor="e", stretch=(column == "message"), |
| 177 | ) |
| 178 | scroll_y = ttk.Scrollbar( |
| 179 | issue_area, orient="vertical", command=self.issue_tree.yview, |
| 180 | ) |
| 181 | scroll_x = ttk.Scrollbar( |
| 182 | issue_area, orient="horizontal", command=self.issue_tree.xview, |
| 183 | ) |
| 184 | self.issue_tree.configure( |
| 185 | yscrollcommand=scroll_y.set, xscrollcommand=scroll_x.set, |
| 186 | ) |
| 187 | self.issue_tree.grid(row=0, column=0, sticky="nsew") |
| 188 | scroll_y.grid(row=0, column=1, sticky="ns") |
| 189 | scroll_x.grid(row=1, column=0, sticky="ew") |
| 190 | issue_area.grid_rowconfigure(0, weight=1) |
| 191 | issue_area.grid_columnconfigure(0, weight=1) |
| 192 | |
| 193 | blocked_features = ( |
| 194 | "• انتخاب شرکت و سال مالی از دیتابیس — هنوز به برنامه دسکتاپ متصل نیست.", |
| 195 | "• ورود و ذخیره اسناد حسابداری — غیرفعال؛ فقط بررسی ساختار فایل ممکن است.", |
| 196 | "• نگاشت حساب به یادداشت و زیریادداشت — هنوز گردش تأیید نهایی ندارد.", |
| 197 | "• تهیه صورت وضعیت مالی، سود و زیان، جریان وجه نقد و حقوق مالکانه — غیرفعال.", |
| 198 | "• کنترل تطبیق و ردیابی اقلام تا حساب و سند منبع — برای پایلوت نهایی لازم است.", |
| 199 | "• بازبینی مستقل، امضای تصمیم، صدور PDF/Excel و چاپ — غیرفعال.", |
| 200 | ) |
| 201 | ttk.Label( |
| 202 | workflow_tab, text="این بخشها هنوز عملیاتی نیستند؛ دکمهٔ نمایشی ندارند.", |
| 203 | anchor="e", justify="right", |
| 204 | font=("Tahoma", 12, "bold"), |
| 205 | ).pack(fill="x", pady=(0, 14)) |
| 206 | for item in blocked_features: |
| 207 | ttk.Label( |
| 208 | workflow_tab, text=item, anchor="e", justify="right", |
| 209 | wraplength=880, font=("Tahoma", 11), |
| 210 | ).pack(fill="x", pady=9) |
| 211 | |
| 212 | ttk.Label( |
| 213 | help_tab, |
| 214 | text=( |
| 215 | "۱. از منوی «فایل» یا دکمهٔ «انتخاب فایل اکسل» یک فایل *.xlsx " |
| 216 | "منطبق با قالب پایلوت باز کنید.\n\n" |
| 217 | "۲. «بررسی فایل» را اجرا کنید؛ خطاها با شیت، ردیف و ستون نمایش داده میشوند.\n\n" |
| 218 | "۳. «پاککردن انتخاب» فقط وضعیت همین پنجره را پاک میکند.\n\n" |
| 219 | "این پایلوت آفلاین کار میکند، هیچ فایل ورودی را تغییر نمیدهد و " |
| 220 | "دادهها را در دیتابیس یا شبکه ثبت نمیکند. " |
| 221 | "موفقیت پیشبررسی صرفاً بررسی قالب و قواعد پایه است، نه " |
| 222 | "تأیید صحت ارقام یا تأیید تهیه صورتهای مالی." |
| 223 | ), |
| 224 | anchor="e", justify="right", wraplength=880, |
| 225 | font=("Tahoma", 12), |
| 226 | ).pack(fill="x") |
| 227 | |
| 228 | ttk.Label( |
| 229 | outer, textvariable=self.status, anchor="e", |
| 230 | style="Pilot.TLabel", |
| 231 | ).pack(fill="x", pady=(12, 0)) |
| 232 | |
| 233 | def _register_keys(self) -> None: |
| 234 | bindings = { |
| 235 | "<Control-o>": self.open_workbook, |
| 236 | "<Control-r>": self.validate_workbook, |
| 237 | "<Control-l>": self.clear_workbook, |
| 238 | "<Control-q>": self.exit_application, |
| 239 | "<F1>": self.show_about, |
| 240 | } |
| 241 | for sequence, callback in bindings.items(): |
| 242 | self.bind_all(sequence, lambda event, fn=callback: fn()) |
| 243 | |
| 244 | def _refresh_controls(self) -> None: |
| 245 | enabled = self.controller.selected_path is not None |
| 246 | self.validate_button.configure(state="normal" if enabled else "disabled") |
| 247 | self.file_menu.entryconfigure(1, state="normal" if enabled else "disabled") |
| 248 | |
| 249 | def open_workbook(self) -> None: |
| 250 | selected = self._file_picker() |
| 251 | if not selected: # Cancel must not clear the current selection. |
| 252 | return |
| 253 | try: |
| 254 | self.controller.choose_file(selected) |
| 255 | except PilotInputError as exc: |
| 256 | self.file_name.set("فایلی انتخاب نشده است.") |
| 257 | self.summary.set("انتخاب فایل معتبر انجام نشد.") |
| 258 | self.status.set(str(exc)) |
| 259 | else: |
| 260 | self.file_name.set(str(self.controller.selected_path)) |
| 261 | self.summary.set("فایل انتخاب شد؛ بررسی هنوز اجرا نشده است.") |
| 262 | self.status.set("انتخاب فایل به معنی ورود یا ذخیرهٔ اطلاعات نیست.") |
| 263 | self._clear_issues() |
| 264 | self._refresh_controls() |
| 265 | |
| 266 | def validate_workbook(self) -> None: |
| 267 | if self.controller.selected_path is None: |
| 268 | self.status.set("ابتدا فایل اکسل را انتخاب کنید.") |
| 269 | return |
| 270 | self._clear_issues() |
| 271 | try: |
| 272 | checked = self.controller.validate() |
| 273 | except PilotInputError as exc: |
| 274 | self.summary.set("بررسی فایل انجام نشد.") |
| 275 | self.status.set(str(exc)) |
| 276 | else: |
| 277 | issues = checked.issues |
| 278 | for issue in issues[:MAX_VISIBLE_ISSUES]: |
| 279 | self.issue_tree.insert( |
| 280 | "", "end", |
| 281 | values=( |
| 282 | issue.severity, issue.code, issue.sheet, |
| 283 | issue.row, issue.field, issue.message, |
| 284 | ), |
| 285 | ) |
| 286 | if checked.valid: |
| 287 | self.summary.set( |
| 288 | "پیشبررسی قالب با موفقیت گذشت؛ صحت مالی و تأیید حسابرسی اثبات نشده است." |
| 289 | ) |
| 290 | else: |
| 291 | self.summary.set( |
| 292 | f"فایل رد شد: {len(issues)} مورد اخطار/خطای قابل گزارش." |
| 293 | ) |
| 294 | if len(issues) > MAX_VISIBLE_ISSUES: |
| 295 | self.status.set( |
| 296 | f"فقط {MAX_VISIBLE_ISSUES} مورد نخست نمایش داده شد؛ " |
| 297 | "همهٔ خطاها در نتیجهٔ بررسی داخل حافظه موجودند." |
| 298 | ) |
| 299 | else: |
| 300 | self.status.set( |
| 301 | "پیشبررسی تکمیل شد؛ هیچ منبع مالی تغییر داده نشد." |
| 302 | ) |
| 303 | self._refresh_controls() |
| 304 | |
| 305 | def _clear_issues(self) -> None: |
| 306 | items = self.issue_tree.get_children() |
| 307 | if items: |
| 308 | self.issue_tree.delete(*items) |
| 309 | |
| 310 | def clear_workbook(self) -> None: |
| 311 | self.controller.clear() |
| 312 | self._clear_issues() |
| 313 | self.file_name.set("فایلی انتخاب نشده است.") |
| 314 | self.summary.set("ابتدا یک فایل با قالب پایلوت انتخاب کنید.") |
| 315 | self.status.set("انتخاب پاک شد؛ هیچ فایل ورودی حذف نشد.") |
| 316 | self._refresh_controls() |
| 317 | |
| 318 | def exit_application(self) -> None: |
| 319 | self.destroy() |
| 320 | |
| 321 | def show_about(self) -> None: |
| 322 | self._info_dialog( |
| 323 | "درباره آرام", |
| 324 | "ARAM Native Desktop Pilot — UNRELEASED\n" |
| 325 | "فقط پیشبررسی فایل اکسل؛ فاقد تهیه و تأیید صورتهای مالی.\n" |
| 326 | "بدون شبکه، بدون ثبت دیتابیس، بدون دسترسی به دادههای اصلی.", |
| 327 | ) |
| 328 | |
| 329 | |
| 330 | def self_test() -> int: |
| 331 | """Headless import/validation smoke for a frozen Windows executable.""" |
| 332 | from aram_backend.desktop_pilot_core import DesktopPilotController |
| 333 | if DesktopPilotController().state != "EMPTY": |
| 334 | return 3 |
| 335 | result = preflight_pilot_workbook(b"not an xlsx") |
| 336 | if result.valid or not result.issues: |
| 337 | return 4 |
| 338 | if len(PILOT_ACTIONS) != 5: |
| 339 | return 5 |
| 340 | return 0 |
| 341 | |
| 342 | |
| 343 | def ui_smoke_test() -> int: |
| 344 | """Invoke actual native widgets/menus on a synthetic workbook (Windows CI). |
| 345 | |
| 346 | Programmatic Tk widget/OS-menu invocation, NOT a human pointer click or |
| 347 | full end-to-end financial statements acceptance. |
| 348 | """ |
| 349 | from io import BytesIO |
| 350 | from openpyxl import Workbook |
| 351 | |
| 352 | book = Workbook() |
| 353 | book.remove(book.active) |
| 354 | for name, headers in SHEET_HEADERS.items(): |
| 355 | book.create_sheet(name).append(list(headers)) |
| 356 | with tempfile.TemporaryDirectory() as directory: |
| 357 | path = Path(directory) / "synthetic_pilot.xlsx" |
| 358 | book.save(path) |
| 359 | info_calls: list[str] = [] |
| 360 | window = PilotWindow( |
| 361 | file_picker=lambda: str(path), |
| 362 | info_dialog=lambda title, text: info_calls.append(title), |
| 363 | ) |
| 364 | try: |
| 365 | window.withdraw() |
| 366 | window.update_idletasks() |
| 367 | for tab_index in range(window.tabs.index("end")): |
| 368 | window.tabs.select(tab_index) |
| 369 | if window.tabs.index(window.tabs.select()) != tab_index: |
| 370 | return 17 |
| 371 | for key in ("<Control-o>", "<Control-r>", "<Control-l>", "<Control-q>", "<F1>"): |
| 372 | if not window.bind_all(key): |
| 373 | return 18 |
| 374 | if str(window.validate_button.cget("state")) != "disabled": |
| 375 | return 10 |
| 376 | window.file_menu.invoke(0) # open (real Tk menu callback) |
| 377 | if window.controller.selected_path != path: |
| 378 | return 11 |
| 379 | if str(window.validate_button.cget("state")) != "normal": |
| 380 | return 12 |
| 381 | window.validate_button.invoke() # validate (real Tk button) |
| 382 | if window.controller.result is None: |
| 383 | return 13 |
| 384 | window.file_menu.invoke(1) # repeat validation (real Tk menu) |
| 385 | window.help_menu.invoke(0) # about (injected safe dialog) |
| 386 | if len(info_calls) != 1: |
| 387 | return 14 |
| 388 | window.clear_button.invoke() # clear button |
| 389 | if window.controller.selected_path is not None: |
| 390 | return 15 |
| 391 | window.open_button.invoke() # open button, not just menu |
| 392 | if window.controller.selected_path != path: |
| 393 | return 19 |
| 394 | window.file_menu.invoke(2) # clear via menu |
| 395 | if window.controller.selected_path is not None: |
| 396 | return 16 |
| 397 | window.file_menu.invoke(4) # exit via menu |
| 398 | return 0 |
| 399 | finally: |
| 400 | try: |
| 401 | if window.winfo_exists(): |
| 402 | window.destroy() |
| 403 | except tk.TclError: |
| 404 | pass |
| 405 | |
| 406 | |
| 407 | def main(argv: list[str] | None = None) -> int: |
| 408 | args = list(sys.argv[1:] if argv is None else argv) |
| 409 | if args == ["--self-test"]: |
| 410 | return self_test() |
| 411 | if args == ["--ui-smoke"]: |
| 412 | return ui_smoke_test() |
| 413 | if args: |
| 414 | print("Supported: --self-test, --ui-smoke, or no arguments", file=sys.stderr) |
| 415 | return 2 |
| 416 | window = PilotWindow() |
| 417 | window.mainloop() |
| 418 | return 0 |
| 419 | |
| 420 | |
| 421 | if __name__ == "__main__": |
| 422 | raise SystemExit(main()) |