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.
98 lines
3.3 KiB
Python
98 lines
3.3 KiB
Python
from PyQt5.QtWidgets import QApplication, QMainWindow, QToolBar, QMdiArea, QAction, QInputDialog, QDialog, QFormLayout, QLineEdit, \
|
|
QMdiSubWindow, QDialogButtonBox, QWidget, QComboBox, QTabBar, QTabWidget, QGridLayout, QLabel, QPushButton, QSpacerItem,QSizePolicy, QCheckBox, QVBoxLayout
|
|
from UI.AreaSettingWidget import AreaSettingWidget
|
|
from PyQt5.QtCore import Qt
|
|
from PyQt5.QtGui import QPixmap, QIcon
|
|
import sys
|
|
|
|
from model.ProjectModel.DeviceManage import Device
|
|
|
|
|
|
class DelAreaWidget(QDialog):
|
|
def __init__(self, deviceName):
|
|
super().__init__()
|
|
self.checkbox_data ={}
|
|
self.deviceName = deviceName
|
|
self.delAreaRowAndColunm = []
|
|
self.initUI()
|
|
def initUI(self):
|
|
vorlayout = QVBoxLayout() #主布局
|
|
# layout = QGridLayout()
|
|
jsonCons = Device().getAreaJson(self.deviceName)
|
|
row = 1
|
|
if jsonCons is None:
|
|
return
|
|
else:
|
|
for jsoncon in jsonCons:
|
|
varType = jsoncon["type"]
|
|
channelNums = jsoncon["nums"]
|
|
channelBytes = jsoncon["bytes"]
|
|
text = varType + ": " + channelBytes + 'Byte' + '数量:'+ channelNums
|
|
checkbox = QCheckBox(text)
|
|
vorlayout.addWidget(checkbox)
|
|
checkbox.stateChanged.connect(self.checkbox_state_changed)
|
|
self.checkbox_data[checkbox] = row
|
|
row += 1
|
|
|
|
|
|
# for i in self.areaLabel:
|
|
# if self.deviceName in i:
|
|
# widget = i[2]
|
|
# row = i[3]
|
|
# text = widget.text()
|
|
# column = i[4]
|
|
# checkbox = QCheckBox(text)
|
|
#
|
|
# if column > 0:
|
|
# vorlayout.addWidget(checkbox)
|
|
#
|
|
# else:
|
|
# vorlayout.addWidget(checkbox)
|
|
# self.checkbox_data[checkbox] = [row, column]
|
|
|
|
button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
|
ok_button = button_box.button(QDialogButtonBox.Ok)
|
|
ok_button.setText("确定") # 设置Ok按钮的文本
|
|
cancel_button = button_box.button(QDialogButtonBox.Cancel)
|
|
cancel_button.setText("取消") # 设置Cancel按钮的文本
|
|
|
|
button_box.accepted.connect(self.getDelAreaRowAndColunm)
|
|
button_box.rejected.connect(self.reject)
|
|
vorlayout.addWidget(button_box)
|
|
|
|
self.setWindowIcon(QIcon('Static/zhjt.ico'))
|
|
self.setWindowTitle("删除通道")
|
|
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)#去掉标题栏的问号
|
|
self.setLayout(vorlayout)
|
|
|
|
|
|
def checkbox_state_changed(self, state):
|
|
sender = self.sender() # 获取触发信号的对象
|
|
if isinstance(sender, QCheckBox):
|
|
if state == 2: # 选中状态
|
|
self.delAreaRowAndColunm.append(self.checkbox_data[sender]) # 从字典中获取行列信息
|
|
|
|
elif state == 0: # 取消选中状态
|
|
self.delAreaRowAndColunm.remove(self.checkbox_data[sender])
|
|
|
|
def getDelAreaRowAndColunm(self):
|
|
self.accept()
|
|
return self.delAreaRowAndColunm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app = QApplication(sys.argv)
|
|
# Client.initDB()
|
|
window = DelAreaWidget()
|
|
|
|
window.show()
|
|
sys.exit(app.exec_())
|
|
|
|
|
|
|