You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PROFIBUS/UI/AreaSettingWidget.py

48 lines
1.4 KiB
Python

2 years ago
from PyQt5.QtWidgets import QDialog, QFormLayout, QLineEdit, QComboBox, QDialogButtonBox, QApplication
import sys
class AreaSettingWidget(QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.initUI()
def initUI(self):
layout = QFormLayout()
varType = QComboBox()
varType.addItems(['AI', 'AO', 'DI', 'DO'])
varType.setObjectName('varType')
channelNums = QLineEdit()
channelNums.setObjectName('channelNums')
channelBytes = QLineEdit()
channelBytes.setObjectName('channelBytes')
layout.addRow('协议类型:', varType)
layout.addRow('通道数:', channelNums)
layout.addRow("字节长度:", channelBytes)
button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)
layout.addRow(button_box)
self.setLayout(layout)
self.setWindowTitle("通道配置")
def getParameters(self):
varType = self.findChild(QComboBox, "varType").currentText()
channelNums = self.findChild(QLineEdit, "channelNums").text()
channelBytes = self.findChild(QLineEdit, "channelBytes").text()
return varType, channelNums, channelBytes
if __name__ == '__main__':
app = QApplication(sys.argv)
window = AreaSettingWidget()
window.show()
sys.exit(app.exec_())