pySimBlocks.gui.main_window¶
- class pySimBlocks.gui.main_window.MainWindow(project_path: Path)[source]¶
Bases:
QMainWindowMain application window for the pySimBlocks GUI editor.
Assembles the block library panel, diagram canvas, and toolbar. Manages project load/save/run operations and tracks unsaved changes.
- loader¶
Service used to load a project from YAML.
- saver¶
Service used to save a project to YAML.
- runner¶
Service used to launch a simulation.
- block_registry¶
Registry mapping category → block type → BlockMeta.
- project_state¶
Shared mutable state of the currently open project.
- view¶
The diagram canvas widget.
- project_controller¶
Controller coordinating model and view mutations.
- blocks¶
Block-library side panel widget.
- toolbar¶
Toolbar widget with run/save actions.
- get_categories() List[str][source]¶
Return the sorted list of block categories from the registry.
- Returns:
Sorted list of category name strings.
- get_blocks(category: str) List[str][source]¶
Return the sorted list of block type names within a category.
- Parameters:
category – Category name to look up.
- Returns:
Sorted list of block type name strings.
- resolve_block_meta(category: str, block_type: str) BlockMeta[source]¶
Return the
BlockMetafor a given category and block type.- Parameters:
category – Category name of the block.
block_type – Type name of the block within the category.
- Returns:
The
BlockMetadescriptor for the requested block.
- auto_load_detection(project_path: Path) bool[source]¶
Return True if a recognisable project file is found in
project_path.- Parameters:
project_path – Directory to search for a project file.
- Returns:
True if
project.yamlexists in the directory, False otherwise.
- update_window_title() None[source]¶
Refresh the window title to reflect the project name and dirty state.
- on_project_loaded(project_path: Path) None[source]¶
Refresh the window title after a project has been loaded.
- Parameters:
project_path – Path to the newly loaded project directory.
- closeEvent(event) None[source]¶
Intercept the close event to prompt the user about unsaved changes.
- Parameters:
event – Qt close event.
- confirm_discard_or_save(action_name: str) bool[source]¶
Show an unsaved-changes dialog if the project is dirty.
- Parameters:
action_name – Human-readable name of the triggering action (e.g.
'closing'), displayed in the dialog message.- Returns:
True if the action should proceed (user saved or discarded changes), False if the user cancelled.
- staticMetaObject = PySide6.QtCore.QMetaObject("MainWindow" inherits "QMainWindow": )¶