diff --git a/Static/PA块信息表.xlsx b/Static/PA块信息表.xlsx index 7d93c2a..66935d1 100644 Binary files a/Static/PA块信息表.xlsx and b/Static/PA块信息表.xlsx differ diff --git a/UI/BlockParameterManageWidget.py b/UI/BlockParameterManageWidget.py index 6d67eb3..e5e69e1 100644 --- a/UI/BlockParameterManageWidget.py +++ b/UI/BlockParameterManageWidget.py @@ -1,7 +1,4 @@ - -from ast import match_case -from tkinter.ttk import Combobox -from numpy import mat +import re import qtawesome from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QStyledItemDelegate, QStyle, QComboBox, QMessageBox, QPushButton,QStackedWidget, QLineEdit, QVBoxLayout, QHBoxLayout, QWidget, QLabel, QSplitter, QButtonGroup @@ -154,6 +151,7 @@ class BlockParameterManageWidget(QWidget): def __init__(self): super().__init__() self.initUI() + self.initUIstat = True def initUI(self): @@ -169,11 +167,16 @@ class BlockParameterManageWidget(QWidget): self.deviceAddressEdit = QLineEdit() self.deviceAddressEdit.setObjectName("deviceAddressEdit") - self.confirmBtn = QPushButton('加载数据') + self.confirmBtn = QPushButton('确定') self.confirmBtn.setIcon(qtawesome.icon('fa5s.check-circle', color='#1fbb6f')) - self.confirmBtn.clicked.connect(self.refreshData) + self.confirmBtn.clicked.connect(self.loadBlackData) self.confirmBtn.setObjectName("parameBtn") + self.refershDataBtn = QPushButton('加载数据') + self.refershDataBtn.setIcon(qtawesome.icon('fa5s.check-circle', color='#1fbb6f')) + self.refershDataBtn.clicked.connect(self.refreshData) + self.refershDataBtn.setObjectName("parameBtn") + self.deviceAddressSearchBtn = QPushButton('查找') self.deviceAddressSearchBtn.setIcon(qtawesome.icon('fa.search', color='#1fbb6f')) self.deviceAddressSearchBtn.clicked.connect(self.searchAddress) @@ -182,6 +185,7 @@ class BlockParameterManageWidget(QWidget): self.settingLayout.addWidget(self.deviceAddressLabel, 1) self.settingLayout.addWidget(self.deviceAddressEdit, 1) self.settingLayout.addWidget(self.confirmBtn, 1) + self.settingLayout.addWidget(self.refershDataBtn, 1) self.settingLayout.addWidget(self.deviceAddressSearchBtn, 1) # self.settingLayout.addLayout(self.blockLayout) @@ -193,44 +197,44 @@ class BlockParameterManageWidget(QWidget): self.widget = QWidget() self.mainlayout.addWidget(self.widget, 20) - # self.proxy = QtCore.QSortFilterProxyModel(self) - # self.parameTableView.proxy = self.proxy - # self.proxy.setSourceModel(self.parameTableView.model) - - # self.parameTableView.setModel(self.proxy) - - # datas = PressureTranslationBlock.getallParame() - # for index, data in enumerate(datas): - # desc = data[2].replace('\r\n', '').replace('\n', '') - # lines = [desc[i:i+50] + "\r\n" for i in range(0, len(desc), 50)] - # # 合并列表为一个字符串,移除最后一个换行符 - # result = "".join(lines).rstrip("\r\n") - # data[2] = result - # data = data + ['', '', ''] - # self.parameTableView.model.append_data(data) - # self.parameTableView.setVerticalHeader(ParamsVHeader(self, self.parameTableView.model.datas)) self.setLayout(self.mainlayout) - - def refreshData(self): - if self.deviceAddressEdit.text(): - self.splitter.deleteLater() - self.widget.deleteLater() - self.loadingDataWidget = LoadingDataWidget() - self.loadingDataWidget.loadData() - - - self.settingLayout.addLayout(self.blockLayout, 7) - self.settingLayout.addWidget(QSplitter(), 11) - self.mainlayout.addWidget(self.blockLayout.parameStackWidget, 20) - model = self.blockLayout.parameStackWidget.currentWidget().model - model.updateColumn(5, '查询中sdadadsda\r\nsdasdsasasad\r\nasdsadsad...') + + def loadBlackData(self): + address =self.deviceAddressEdit.text() + print(address) + if address: + pattern = re.compile(r'^(?:[1-9]|[1-9][0-9]|1[0-1][0-9]|12[0-5])$') + match = pattern.match(address) + if not match: + QMessageBox.warning(self, '提示', '请输入1 - 125。') + return + if self.initUIstat: + self.splitter.deleteLater() + self.widget.deleteLater() + + self.settingLayout.addLayout(self.blockLayout, 7) + self.settingLayout.addWidget(QSplitter(), 11) + self.mainlayout.addWidget(self.blockLayout.parameStackWidget, 20) + self.initUIstat = False else: reply = QMessageBox.question(self.parent(), '警告', "请输入从站地址", QMessageBox.Yes) return + + def refreshData(self): + + self.loadingDataWidget = LoadingDataWidget() + self.loadingDataWidget.loadData() + model = self.blockLayout.parameStackWidget.currentWidget().model + model.updateColumn(5, '查询中sdadadsda\r\nsdasdsasasad\r\nasdsadsad...') + + + + + def searchAddress(self): self.searchAddressWidget = SearchAddressWidget(self.deviceAddressEdit) diff --git a/UI/BlockParameterModel.py b/UI/BlockParameterModel.py index 48c88d5..d97594f 100644 --- a/UI/BlockParameterModel.py +++ b/UI/BlockParameterModel.py @@ -150,8 +150,8 @@ class VarButtonDelegate(QItemDelegate): dataType = self.parent().model.datas[index.row()][3] objectType = self.parent().model.datas[index.row()][1] - objectTypeEditlayout = ObjectTypeEditlayout(objectType, dataType) - editlineLayout = objectTypeEditlayout.initUI() + editlineLayout = ObjectTypeEditlayout(objectType, dataType) + # editlineLayout = objectTypeEditlayout.initUI() startActionBtn.index = [index.row(), index.column()] startActionBtn.setToolTip('强制') @@ -174,11 +174,11 @@ class VarButtonDelegate(QItemDelegate): boxLayout.addWidget(startActionBtn) boxLayout.addWidget(refreshButton) - startActionBtn.clicked.connect(lambda: self.startAction(objectTypeEditlayout)) + startActionBtn.clicked.connect(lambda: self.startAction(editlineLayout)) startActionBtn.setObjectName('startActionBtn') - boxLayout.setContentsMargins(2, 0, 0, 2) - boxLayout.setAlignment(Qt.AlignCenter) + boxLayout.setContentsMargins(0, 0, 0, 0) + # boxLayout.setAlignment(Qt.AlignCenter) widget = QWidget() widget.setLayout(boxLayout) self.parent().setIndexWidget( @@ -219,6 +219,7 @@ class VarButtonDelegate(QItemDelegate): self.loadingDataWidget = LoadingDataWidget() self.loadingDataWidget.loadData() + self.parent().resizeHeader() class ComboBoxDelegate(QStyledItemDelegate): def __init__(self, parent=None): diff --git a/UI/BlockParameterView.py b/UI/BlockParameterView.py index e08e8e7..2a2190e 100644 --- a/UI/BlockParameterView.py +++ b/UI/BlockParameterView.py @@ -17,8 +17,14 @@ class ParamsVHeader(QHeaderView): for index, content in enumerate(self.datas): self.setSectionResizeMode(index, QHeaderView.Fixed) - self.resizeSection(index, 50 * (content[2].count('\r\n') + 1)) - + desHeight = 50 * (content[2].count('\r\n') + 1) + valueHeight = 50 * (content[5].count('\r\n') + 1) + height = desHeight if desHeight > valueHeight else valueHeight + self.resizeSection(index, height) + if content[3] == 'DS-36': + self.resizeSection(index, height) + if content[3] == 'DS-34': + self.resizeSection(index, height) return @@ -79,12 +85,15 @@ class ParmView(QTableView): self.datas = self.dbModel.getallParame() for index, data in enumerate(self.datas): desc = data[2].replace('\r\n', '').replace('\n', '') - lines = [desc[i:i+50] + "\r\n" for i in range(0, len(desc), 50)] + lines = [desc[i:i+40] + "\r\n" for i in range(0, len(desc), 40)] # 合并列表为一个字符串,移除最后一个换行符 result = "".join(lines).rstrip("\r\n") data[2] = result data = data + ['', '', ''] self.model.append_data(data) + self.resizeHeader() + + def resizeHeader(self): self.setVerticalHeader(ParamsVHeader(self, self.model.datas)) diff --git a/UI/ObjectTypeEditlayout.py b/UI/ObjectTypeEditlayout.py index b8aecfb..7792000 100644 --- a/UI/ObjectTypeEditlayout.py +++ b/UI/ObjectTypeEditlayout.py @@ -7,6 +7,7 @@ class ObjectTypeEditlayout(QVBoxLayout): self.objectType = objectType self.dataType = dataType self.editlineList = [] + self.initUI() def initUI(self): @@ -27,10 +28,10 @@ class ObjectTypeEditlayout(QVBoxLayout): self.editlineList.extend([self.editline1, self.editline2]) if self.dataType == 'DS-36': - self.editline1.setPlaceholderText('请输入高标标度值') - self.editline2.setPlaceholderText('请输入低标标度值') - self.editline3.setPlaceholderText('请输入高标标度值') - self.editline4.setPlaceholderText('请输入高标标度值') + self.editline1.setPlaceholderText('EU_at_lOO %') + self.editline2.setPlaceholderText('EU_at 0%') + self.editline3.setPlaceholderText('单位索引') + self.editline4.setPlaceholderText('有效小数点') self.addWidget(self.editline1) self.addWidget(self.editline2) @@ -59,8 +60,8 @@ class ObjectTypeEditlayout(QVBoxLayout): self.editline1.setPlaceholderText('请输入值') self.addWidget(self.editline1) self.editlineList.append(self.editline1) - - return self + self.setContentsMargins(0,0,0,0) + def getEditlineValue(self): valueList = []