A Python/PyQt6 desktop application that lets you launch and configure any OpenModelica-compiled simulation executable through a clean graphical user interface — no command line required.
OpenModelica compiles Modelica models into standalone Windows executables.
These executables accept simulation flags (-startTime, -stopTime, etc.)
as command-line arguments, which is inconvenient for users who are not
familiar with the command line.
This application wraps that workflow in a simple GUI:
- Browse to the compiled
.exe - Enter a start time and stop time
- Click Run Simulation
The app validates all inputs before running, streams the simulation output into the window, and reports success or failure clearly.
OpenModelica-PyQt-Desktop-App/
├── app/
│ ├── __init__.py # Makes app/ a Python package
│ └── main_window.py # MainWindow class — all GUI and simulation logic
├── simulation/
│ ├── TwoConnectedTanks.exe
│ ├── TwoConnectedTanks_init.xml
│ └── *.dll # OpenModelica runtime DLLs (self-contained)
├── main.py # Entry point — creates QApplication and shows MainWindow
├── requirements.txt # Python dependencies
└── README.md
| Requirement | Version |
|---|---|
| Python | 3.6 or higher |
| PyQt6 | 6.0 or higher |
| OS | Windows (64-bit) |
Note: OpenModelica does not need to be installed on the target machine. All required DLLs are bundled in the
simulation/folder.
# Clone or download the repository
git clone https://github.com/ekagrazi/OpenModelica-PyQt-Desktop-App.git
cd OpenModelica-PyQt-Desktop-App
# Install the Python dependency
pip install -r requirements.txtpython main.py-
Browse — Click the Browse button next to the first field and select the OpenModelica-compiled
.exe(e.g.simulation/TwoConnectedTanks.exe). -
Start Time — Enter an integer ≥ 0 (e.g.
0). -
Stop Time — Enter an integer that is greater than Start Time and strictly less than 5 (e.g.
4).Constraint:
0 ≤ startTime < stopTime < 5 -
Run Simulation — Click the ▶ Run Simulation button. The output box displays the command that was run, the simulation output, and a success or error message.
| Field | Value |
|---|---|
| Executable | simulation/TwoConnectedTanks.exe |
| Start Time | 0 |
| Stop Time | 4 |
The app constructs and executes:
TwoConnectedTanks.exe -startTime=0 -stopTime=4
| Bad input | Error shown |
|---|---|
| No executable selected | "Executable path is empty." |
| Non-integer start/stop | "Start time '...' is not a valid integer." |
| start ≥ stop | "Times must satisfy 0 ≤ start < stop < 5" |
| stop ≥ 5 | "Times must satisfy 0 ≤ start < stop < 5" |
The application follows a clean MVC-like separation:
main.py— bootstrap only (createsQApplication, shows window).app/main_window.py— theMainWindowclass encapsulates all GUI construction (_build_ui), input validation (_validate_inputs), file browsing (_browse_executable), and simulation execution (_run_simulation).
Simulation is launched via Python's subprocess.run with:
capture_output=True— both stdout and stderr are captured.cwdset to the folder containing the exe — so the exe can find its companion.xmldata files next to it.timeout=60— the run is aborted and an error dialog is shown if the simulation takes longer than 60 seconds.
| Technology | Role |
|---|---|
| Python 3 | Application language |
| PyQt6 | Cross-platform GUI framework |
| OpenModelica | Modelica model compiler / simulation engine |
| subprocess | Launching the simulation executable |
| Windows 64-bit | Target operating system |