-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_widget.cpp
More file actions
executable file
·70 lines (58 loc) · 2.19 KB
/
python_widget.cpp
File metadata and controls
executable file
·70 lines (58 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "python_widget.hpp"
PythonWidget::PythonWidget(QWidget *parent):QWidget(parent), data(){
// Initialize tab views
log = new LogView();
proView = nullptr;
if (!data.loadJson())
log->write("Error: fail to load user data from json file.");
hiddenVar = new HiddenVarView(&data, log);
general = new GeneralViewPy("python", &data, log, hiddenVar);
core = new CorePy(this, general, hiddenVar, log);
QObject::connect(general, &GeneralViewPy::run, core, &CorePy::runPython);
switchButton = new QPushButton("Switch to Matlab Version");
QObject::connect(switchButton, &QPushButton::clicked, this, &PythonWidget::closeWindow);
infoButton = new QToolButton();
infoButton->setIcon(style()->standardIcon(QStyle::SP_FileDialogInfoView));
infoButton->setStyleSheet("border-radius: 13px");
QObject::connect(infoButton, &QPushButton::clicked, this, &PythonWidget::infoClicked);
tabView = new QTabWidget();
tabView->addTab(general, "General");
tabView->addTab(hiddenVar, "Hidden Parameters");
tabView->addTab(log, "Log History");
QGridLayout *layout = new QGridLayout();
layout->addWidget(tabView, 0, 0, 5, 5);
layout->addWidget(infoButton, 5, 3, Qt::AlignRight);
layout->addWidget(switchButton, 5, 4, Qt::AlignRight);
setLayout(layout);
setWindowTitle("CellTrack_GUI -- Python");
resize(800, 650);
}
void PythonWidget::closeEvent(QCloseEvent *event) {
data.setPysource(general->getVideoPath());
data.setPyprogram(general->getAppPath());
if(!data.saveJson())
log->write("Error: Fail to save data into the json file.");
QWidget::closeEvent(event);
}
void PythonWidget::closeWindow() {
close();
createView(1);
}
void PythonWidget::infoClicked() {
QDialog *dialog;
switch (tabView->currentIndex()) {
case 0:
dialog = new HelperWidget("py_general");
break;
case 1:
dialog = new HelperWidget("py_hidden");
break;
case 2:
dialog = new HelperWidget("log");
break;
default:
dialog = new HelperWidget("");
break;
}
dialog->exec();
}