-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathoptionsdialog.py
96 lines (75 loc) · 2.59 KB
/
optionsdialog.py
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from PyQt6.QtWidgets import QDialogButtonBox, QHBoxLayout, QMainWindow
from PyQt6.QtWidgets import QDialog
from PyQt6.QtWidgets import QWidget,QGroupBox
from PyQt6.QtWidgets import QMessageBox,QVBoxLayout,QCheckBox,QButtonGroup,QPushButton,QLabel,QSpinBox,QComboBox
from PyQt6 import uic
import main
from helper import res_path,classlistToIds
class OptionsDialog(QDialog):
def __init__(self,dialog, parent):
QDialog.__init__(self, parent)
self.initialized = False
self.main = parent #type: main.MainUi
self.layout = QVBoxLayout()
self.setWindowTitle(dialog.name)
self.setDialog(dialog)
def initBaseUI(self):
self.initialized = True
self.conf_ui.initUI()
self.layout.addWidget(self.conf_ui)
okbtn = QPushButton("OK")
okbtn.clicked.connect(self.ok)
cancelButton = QPushButton("Cancel")
cancelButton.clicked.connect(self.reject)
applyButton = QPushButton("Apply")
applyButton.clicked.connect(self.apply)
btnGroup = QDialogButtonBox()
btnGroup.addButton(okbtn, QDialogButtonBox.ButtonRole.AcceptRole)
btnGroup.addButton(cancelButton, QDialogButtonBox.ButtonRole.RejectRole)
btnGroup.addButton(applyButton, QDialogButtonBox.ButtonRole.ApplyRole)
self.layout.addWidget(btnGroup)
self.setLayout(self.layout)
def ok(self):
self.apply()
self.accept()
def apply(self):
self.conf_ui.apply()
# def closeEvent(self, a0) -> None:
# print("close")
# self.onclose()
# return super().closeEvent(a0)
def hideEvent(self, a0) -> None:
self.onclose()
return super().hideEvent(a0)
def onclose(self):
self.conf_ui.onclose()
def exec(self) -> None:
try:
if not self.initialized:
self.initBaseUI()
self.conf_ui.readValues()
self.conf_ui.onshown()
except Exception as e:
self.main.log("Error getting info")
print(e)
return super().exec()
def setDialog(self,dialog):
self.conf_ui = dialog
class OptionsDialogGroupBox(QGroupBox):
name = "Options"
def __init__(self,name,main):
self.name = name
self.main = main
QGroupBox.__init__(self,name)
def initUI(self):
vbox = QVBoxLayout()
vbox.addWidget(QLabel("Error. No dialog for\n" + self.name))
self.setLayout(vbox)
def apply(self):
pass
def readValues(self):
pass
def onshown(self):
pass
def onclose(self):
pass