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.
80 lines
2.6 KiB
Python
80 lines
2.6 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 AreaSettingWidget import AreaSettingWidget
|
|
from PyQt5.QtCore import Qt
|
|
from PyQt5.QtGui import QPixmap, QIcon
|
|
import sys
|
|
|
|
|
|
|
|
|
|
class DelAreaWidget(QDialog):
|
|
def __init__(self, areaLabel, deviceName):
|
|
super().__init__()
|
|
self.checkbox_data ={}
|
|
self.areaLabel = areaLabel
|
|
self.deviceName = deviceName
|
|
self.delAreaRowAndColunm = []
|
|
self.initUI()
|
|
def initUI(self):
|
|
|
|
vorlayout = QVBoxLayout() #主布局
|
|
layout = QGridLayout()
|
|
|
|
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)
|
|
checkbox.stateChanged.connect(self.checkbox_state_changed)
|
|
if column > 0:
|
|
layout.addWidget(checkbox, row, 1)
|
|
self.checkbox_data[checkbox] = [row, 1]
|
|
else:
|
|
layout.addWidget(checkbox, row, column)
|
|
self.checkbox_data[checkbox] = [row, column]
|
|
|
|
button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
|
button_box.accepted.connect(self.getDelAreaRowAndColunm)
|
|
button_box.rejected.connect(self.reject)
|
|
vorlayout.addLayout(layout)
|
|
vorlayout.addWidget(button_box)
|
|
|
|
self.setWindowIcon(QIcon('../Static/zhjt.ico'))
|
|
self.setWindowTitle("删除通道")
|
|
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint)#去掉标题栏的问号
|
|
self.setLayout(vorlayout)
|
|
self.exec_()
|
|
|
|
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.close()
|
|
return self.delAreaRowAndColunm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app = QApplication(sys.argv)
|
|
# Client.initDB()
|
|
window = DelAreaWidget()
|
|
|
|
window.show()
|
|
sys.exit(app.exec_())
|
|
|
|
|
|
|