|
|
|
@ -14,7 +14,21 @@ class DeviceDialog(QDialog):
|
|
|
|
|
deviceName = QLineEdit()
|
|
|
|
|
deviceName.setObjectName('deviceName')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pvUpperLimit = QLineEdit()
|
|
|
|
|
pvUpperLimit.setObjectName('pvUpperLimit')
|
|
|
|
|
|
|
|
|
|
pvLowerLimit = QLineEdit()
|
|
|
|
|
pvLowerLimit.setObjectName('pvLowerLimit')
|
|
|
|
|
|
|
|
|
|
pvUnit = QLineEdit()
|
|
|
|
|
pvUnit.setObjectName('pvUnit')
|
|
|
|
|
|
|
|
|
|
layout.addRow("设备名:", deviceName)
|
|
|
|
|
layout.addRow("量程上限:", pvUpperLimit)
|
|
|
|
|
layout.addRow("量程下限:", pvLowerLimit)
|
|
|
|
|
layout.addRow("单位:", pvUnit)
|
|
|
|
|
|
|
|
|
|
button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
|
|
|
|
ok_button = button_box.button(QDialogButtonBox.Ok)
|
|
|
|
@ -35,11 +49,22 @@ class DeviceDialog(QDialog):
|
|
|
|
|
|
|
|
|
|
def getParameters(self):
|
|
|
|
|
deviceName = self.findChild(QLineEdit, "deviceName").text()
|
|
|
|
|
return deviceName
|
|
|
|
|
pvUpperLimit = self.findChild(QLineEdit, "pvUpperLimit").text()
|
|
|
|
|
pvLowerLimit = self.findChild(QLineEdit, "pvLowerLimit").text()
|
|
|
|
|
pvUnit = self.findChild(QLineEdit, "pvUnit").text()
|
|
|
|
|
return deviceName, pvUpperLimit, pvLowerLimit, pvUnit
|
|
|
|
|
|
|
|
|
|
def check_input(self):
|
|
|
|
|
deviceName = self.getParameters()
|
|
|
|
|
if not deviceName:
|
|
|
|
|
QMessageBox.warning(self, '警告', '请输入设备名')
|
|
|
|
|
deviceName, pvUpperLimit, pvLowerLimit, pvUnit = self.getParameters()
|
|
|
|
|
|
|
|
|
|
if not pvUpperLimit or not pvLowerLimit or not pvUnit or not deviceName:
|
|
|
|
|
QMessageBox.warning(self, '警告', '有值未输入。')
|
|
|
|
|
return
|
|
|
|
|
elif not re.match(r'^[-+]?\d*\.?\d*$', pvUpperLimit) or not re.match(r'^[-+]?\d*\.?\d*$', pvLowerLimit):
|
|
|
|
|
QMessageBox.warning(self, '警告', '请输入数字。')
|
|
|
|
|
return
|
|
|
|
|
elif pvUpperLimit < pvLowerLimit:
|
|
|
|
|
QMessageBox.warning(self, '警告', '量程输入有误。')
|
|
|
|
|
return
|
|
|
|
|
else:
|
|
|
|
|
self.accept() # 所有输入都是数字且不为空时接受对话框
|