MainApp
- class gpype.frontend.main_app.MainApp[source]
Bases:
objectMain application class for g.Pype frontend applications.
Provides framework for creating PyQt6-based applications with widget management, window configuration, and lifecycle handling. Uses composition for better flexibility and testability.
- DEFAULT_POSITION = [100, 100, 700, 400]
Default window geometry configuration
- DEFAULT_GRID_SIZE = [3, 3]
Default grid size (rows, cols)
- ICON_PATH = WindowsPath('resources/gtec.ico')
Application icon path
- __init__(caption='g.Pype Application', position=None, grid_size=None, app=None, prevent_sleep=True)[source]
Initialize the main application with window and widget management.
- Parameters:
caption (
str) – Window title text displayed in the title bar.position (
list[int]) – Window geometry as [x, y, width, height] list. Uses DEFAULT_POSITION if None.grid_size (
list[int]) – Grid dimensions as [rows, cols] list. Uses DEFAULT_GRID_SIZE if None.app – Existing QApplication instance for testing or integration. Creates new QApplication if None.
prevent_sleep (
bool) – Whether to prevent system sleep/power saving. Default True for real-time applications.
- add_widget(widget, grid_positions=None)[source]
Add a widget to the application layout and management system.
Registers the widget for lifecycle management and adds it to the main window’s grid layout. Widget will be automatically started during run() and terminated during shutdown.
- run()[source]
Start the application and enter the main event loop.
Shows the main window, starts all registered widgets, enables sleep prevention if configured, and enters the Qt event loop. Blocks until the application is closed.
- Returns:
- Application exit code. 0 indicates successful execution,
non-zero values indicate errors or abnormal termination.
- Return type: