|
|
|
@ -7,7 +7,7 @@ from PyQt5.QtWidgets import QApplication, QMainWindow, QToolBar, QMdiArea, QActi
|
|
|
|
|
QMdiSubWindow, QDialogButtonBox, QWidget, QComboBox, QTabBar, QTabWidget, QGridLayout, QLabel, QPushButton, QSpacerItem, QSizePolicy, QHBoxLayout, QTableWidget, QScrollArea
|
|
|
|
|
from PyQt5 import QtCore
|
|
|
|
|
from PyQt5.QtGui import QPixmap, QIcon
|
|
|
|
|
from DeviceWidget import *
|
|
|
|
|
from UI.DeviceWidget import DeviceDialog
|
|
|
|
|
from UI.AreaSettingWidget import AreaSettingWidget
|
|
|
|
|
from UI.DelAreaWidget import DelAreaWidget
|
|
|
|
|
# from model.ProjectModel.AreaManage import Devices, DevicesManange, Area
|
|
|
|
@ -15,6 +15,14 @@ from protocol.ModBus.ModBusThread import MyThread
|
|
|
|
|
from utils.DBModels.BaseModel import *
|
|
|
|
|
# from utils.DBModels.ClientModels import DeviceDB
|
|
|
|
|
# from model.ClientModel.Client import Client
|
|
|
|
|
class CommonHelper:
|
|
|
|
|
def __init__(self):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def readQss(style):
|
|
|
|
|
with open(style,"r") as f:
|
|
|
|
|
return f.read()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MainWindow(QMainWindow):
|
|
|
|
@ -35,8 +43,10 @@ class MainWindow(QMainWindow):
|
|
|
|
|
self.addToolBar(self.toolbar)
|
|
|
|
|
# self.setWindowState(self.windowState() | QtCore.Qt.WindowMaximized)
|
|
|
|
|
self.action1 = QAction("添加设备", self)
|
|
|
|
|
self.action1.setObjectName("action1")
|
|
|
|
|
self.action1.triggered.connect(self.createDeciveWidget)
|
|
|
|
|
self.action2 = QAction("开始通讯", self)
|
|
|
|
|
self.action2.setObjectName("action2")
|
|
|
|
|
self.action2.triggered.connect(self.startProtocol)
|
|
|
|
|
|
|
|
|
|
self.toolbar.addAction(self.action1)
|
|
|
|
@ -47,7 +57,7 @@ class MainWindow(QMainWindow):
|
|
|
|
|
# self.scrollArea.setWidget(self.mdi_area)
|
|
|
|
|
|
|
|
|
|
self.setCentralWidget(self.mdi_area)
|
|
|
|
|
self.setWindowIcon(QIcon('../Static/zhjt.ico'))
|
|
|
|
|
self.setWindowIcon(QIcon('Static/zhjt.ico'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# self.mdi_area.setViewMode(QMdiArea.TabbedView)
|
|
|
|
@ -101,7 +111,8 @@ class MainWindow(QMainWindow):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def deviceWidget(self, windowTitle):
|
|
|
|
|
sub_window = AreaQMdiSubWindow() # 创建一个子窗口
|
|
|
|
|
sub_window = AreaQMdiSubWindow()# 创建一个子窗口
|
|
|
|
|
sub_window.setObjectName('sub_window')
|
|
|
|
|
areaLayout1 = QGridLayout()
|
|
|
|
|
areaLayout2 = QGridLayout()
|
|
|
|
|
|
|
|
|
@ -140,7 +151,8 @@ class MainWindow(QMainWindow):
|
|
|
|
|
sub_window.setWindowTitle(windowTitle)
|
|
|
|
|
sub_window.setGeometry(0, 0, 600, 500)
|
|
|
|
|
sub_window.setWidget(scroll_widget)
|
|
|
|
|
sub_window.setWindowIcon(QIcon('../Static/zhjt.ico'))
|
|
|
|
|
sub_window.setWindowIcon(QIcon('Static/zhjt.ico'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.mdi_area.addSubWindow(sub_window) # 将子窗口添加到MDI区域
|
|
|
|
|
# self.mdi_area.subWindowActivated.connect(self.adjustMdiAreaSize)
|
|
|
|
@ -243,11 +255,9 @@ class MainWindow(QMainWindow):
|
|
|
|
|
print(rowAndColumn)
|
|
|
|
|
row = rowAndColumn[0]
|
|
|
|
|
column = rowAndColumn[1]
|
|
|
|
|
print(row, column)
|
|
|
|
|
if column == 0:
|
|
|
|
|
for i in range(4):
|
|
|
|
|
widget = areaLayout.itemAtPosition(row, i).widget()
|
|
|
|
|
print(widget)
|
|
|
|
|
areaLayout.removeWidget(widget)
|
|
|
|
|
widget.deleteLater()
|
|
|
|
|
#删除self.areaLabel列表中的对象
|
|
|
|
@ -257,7 +267,6 @@ class MainWindow(QMainWindow):
|
|
|
|
|
else:
|
|
|
|
|
for i in range(4,8):
|
|
|
|
|
widget = areaLayout.itemAtPosition(row, i).widget()
|
|
|
|
|
print(widget)
|
|
|
|
|
areaLayout.removeWidget(widget)
|
|
|
|
|
widget.deleteLater()
|
|
|
|
|
# 删除self.areaLabel列表中的对象
|
|
|
|
|