Merge branch 'python'

This commit is contained in:
Carl Philipp Klemm 2025-10-13 17:03:05 +02:00
commit f802708af4
7 changed files with 174 additions and 1 deletions

View file

@ -15,7 +15,8 @@ MainWindow::MainWindow(QWidget *parent):
codeEditor(this),
pythonOutput(this),
currentFilePath(""),
isFileModified(false)
isFileModified(false),
pythonRunner(nullptr)
{
ui->setupUi(this);
enumerateDevices();
@ -49,6 +50,11 @@ MainWindow::MainWindow(QWidget *parent):
isFileModified = true;
updateStatus();
});
// Connect Run and Stop buttons
pythonRunner = new PythonRunner(&pythonOutput, this);
connect(ui->pushButtonRun, &QPushButton::clicked, this, &MainWindow::onPushButtonRunClicked);
connect(ui->pushButtonStop, &QPushButton::clicked, this, &MainWindow::onPushButtonStopClicked);
}
MainWindow::~MainWindow()
@ -226,6 +232,19 @@ void MainWindow::enumerateDevices()
generateExample();
}
void MainWindow::onPushButtonRunClicked() {
QString scriptContent = codeEditor.toPlainText();
pythonRunner->runScript(scriptContent);
ui->pushButtonRun->setEnabled(false);
ui->pushButtonStop->setEnabled(true);
}
void MainWindow::onPushButtonStopClicked() {
pythonRunner->stopScript();
ui->pushButtonRun->setEnabled(true);
ui->pushButtonStop->setEnabled(false);
}
void MainWindow::generateExample()
{
QString example =