-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
portconf_ui.py
79 lines (65 loc) · 3.07 KB
/
portconf_ui.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
from PyQt6.QtWidgets import 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
from optionsdialog import OptionsDialog,OptionsDialogGroupBox
from base_ui import CommunicationHandler
class CanOptionsDialog(OptionsDialog):
class CanOptionsDialogBox(OptionsDialogGroupBox,CommunicationHandler):
def __init__(self,name,main,instance):
self.instance = instance
OptionsDialogGroupBox.__init__(self,name,main)
CommunicationHandler.__init__(self)
def initUI(self):
layout = QVBoxLayout()
self.speedBox = QComboBox()
layout.addWidget(QLabel("CAN baud rate:"))
layout.addWidget(self.speedBox)
self.get_value_async("can","speed",self.updateSpeedCb,self.instance,typechar='!')
self.get_value_async("can","speed",self.speedBox.setCurrentIndex,self.instance,typechar='?',conversion=int)
self.setLayout(layout)
def updateSpeedCb(self,val):
self.speedBox.clear()
for entry in val.split("\n"):
name,id = entry.split(":")
self.speedBox.addItem(name,id)
def apply(self):
self.send_value("can","speed",self.speedBox.currentData(),instance=self.instance)
def onclose(self):
self.remove_callbacks()
def getSpeedName(self):
return self.conf_ui.speedBox.currentText()
def __init__(self,instance,name, main):
self.main = main
self.name = name
OptionsDialog.__init__(self,self.CanOptionsDialogBox(name,main,instance),main)
class I2COptionsDialog(OptionsDialog):
class I2COptionsDialogBox(OptionsDialogGroupBox,CommunicationHandler):
def __init__(self,name,main,instance):
self.instance = instance
OptionsDialogGroupBox.__init__(self,name,main)
CommunicationHandler.__init__(self)
def initUI(self):
layout = QVBoxLayout()
self.speedBox = QComboBox()
layout.addWidget(QLabel("I2C baud rate:"))
layout.addWidget(self.speedBox)
self.get_value_async("i2c","speed",self.updateSpeedCb,self.instance,typechar='!')
self.get_value_async("i2c","speed",self.speedBox.setCurrentIndex,self.instance,typechar='?',conversion=int)
self.setLayout(layout)
def updateSpeedCb(self,val):
self.speedBox.clear()
for entry in val.split("\n"):
name,id = entry.split(":")
self.speedBox.addItem(name,id)
def apply(self):
self.send_value("i2c","speed",self.speedBox.currentData(),instance=self.instance)
def onclose(self):
self.remove_callbacks()
def __init__(self,instance,name, main):
self.main = main
self.name = name
OptionsDialog.__init__(self,self.I2COptionsDialogBox(name,main,instance),main)