| 8 | |
| 9 | |
| 10 | def main(): |
| 11 | # Tee stdout/stderr so terminal output is also captured to the current |
| 12 | # schematic's txt/<name>.log (see project.set_current / logfile). |
| 13 | logfile.install() |
| 14 | parser = argparse.ArgumentParser(prog="slicap-schematic-gui") |
| 15 | parser.add_argument( |
| 16 | "--config", |
| 17 | choices=["basic", "full"], |
| 18 | default="full", |
| 19 | help="Symbol library set: 'basic' loads only Symbols.svg; 'full' loads all system SVGs (default).", |
| 20 | ) |
| 21 | parser.add_argument( |
| 22 | "file", |
| 23 | nargs="?", |
| 24 | default=None, |
| 25 | help="Schematic file to open at startup (.slicap_sch).", |
| 26 | ) |
| 27 | args = parser.parse_args() |
| 28 | |
| 29 | app = QApplication(sys.argv) |
| 30 | try: |
| 31 | window = MainWindow(config=args.config, file=args.file) |
| 32 | except SymbolError as exc: |
| 33 | # A malformed symbol definition is the user's to fix, in the SVG file — |
| 34 | # we report it clearly and stop rather than guessing a correction. |
| 35 | print(f"Symbol library error: {exc}", file=sys.stderr) |
| 36 | QMessageBox.critical( |
| 37 | None, "Symbol library error", |
| 38 | f"{exc}\n\nPlease fix the symbol SVG file, then restart.", |
| 39 | ) |
| 40 | sys.exit(1) |
| 41 | except Exception as exc: |
| 42 | import traceback |
| 43 | traceback.print_exc() |
| 44 | sys.exit(1) |
| 45 | window.show() |
| 46 | sys.exit(app.exec()) |
| 47 | |
| 48 | |
| 49 | if __name__ == "__main__": |