Implementation using python invocation using qprocess

This commit is contained in:
Carl Philipp Klemm 2025-10-13 16:30:44 +02:00
parent cd67e8ddd7
commit 66937e2cfc
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 =