-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUiWindow.py
More file actions
126 lines (95 loc) · 4.18 KB
/
UiWindow.py
File metadata and controls
126 lines (95 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5 import QtCore, QtGui, QtWidgets
class MyQLabel(QtWidgets.QLabel):
button_clicked_signal = QtCore.pyqtSignal()
def __init__(self, parent=None):
super(MyQLabel, self).__init__(parent)
def mouseReleaseEvent(self, QMouseEvent):
self.button_clicked_signal.emit()
def connect_customized_slot(self, func):
self.button_clicked_signal.connect(func)
class MyWidget(QWidget):
def __init__(self, parent=None):
super(MyWidget, self).__init__(parent)
self.actionLabel = QTextEdit(self)
self.actionLabel.setObjectName("cameraOneAction")
self.actionLabel.setStyleSheet("background:transparent")
self.actionLabel.setFrameStyle(QFrame.NoFrame)
self.actionLabel.setReadOnly(True)
self.actionLabel.resize(200, 80)
self.imageLabel = QLabel(self)
# self.imageLabel.setMaximumSize(475, 267)
self.imageLabel.setMinimumSize(475, 267)
# self.imageLabel.setMaximumSize(475, 267)
# self.imageLabel.setScaledContents(True)
self.actionLabel.raise_()
self.lastLabel = '未接收到动作'
def imageStyleSheet(self, style):
self.imageLabel.setStyleSheet(style)
return self
def setActionLabel(self, label: str):
self.lastLabel = label or self.lastLabel
self.actionLabel.setPlainText(self.lastLabel)
self.actionLabel.setFontPointSize(25)
self.actionLabel.setTextColor(QColor(240, 65, 85))
def setImage(self, image: QPixmap):
self.imageLabel.setPixmap(image)
self.imageLabel.repaint()
def paintEvent(self, event: QtGui.QPaintEvent) -> None:
self.imageLabel.resize(self.size())
class MyWindow(QWidget):
def __init__(self, parent=None):
super(MyWindow, self).__init__(parent)
self.setupUi()
def setupUi(self):
gridLayout = QGridLayout()
self.buttonLabel = MyQLabel(self)
# self.buttonLabel.setStyleSheet("background:#3c4046")
self.buttonLabel.setStyleSheet("background-color:black")
self.buttonLabel.setText("点击这里开始展示")
self.buttonLabel.setStyleSheet("color:white")
self.buttonLabel.setAlignment(Qt.AlignCenter)
self.labelNoSignal = QLabel()
self.labelNoSignal.setText("No Signal")
self.labelNoSignal.setAlignment(Qt.AlignCenter)
self.labelNoSignal.setStyleSheet("background:black")
self.labelNoSignal.setStyleSheet("color:white")
cameraID = ['0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', '空', '空']
self.screenByCamera = {}
positions = [(i, j) for i in range(0, 3) for j in range(0, 4)]
for position, cameraID in zip(positions, cameraID):
if cameraID == '空':
continue
else:
self.widget = MyWidget(self).imageStyleSheet("background:#3c4046")
self.screenByCamera[cameraID] = self.widget
gridLayout.addWidget(self.widget, *position)
gridLayout.addWidget(self.buttonLabel, 2, 2)
gridLayout.addWidget(self.labelNoSignal, 2, 3)
gridLayout.setSpacing(2)
gridLayout.setContentsMargins(2, 2, 2, 2) # 设置外边距--控件到窗口边框的距离 左上右下
self.setLayout(gridLayout)
class MyMainWindow(QMainWindow):
def __init__(self,):
super().__init__()
self.initUI()
def initUI(self):
self.setGeometry(0, 0, 1920, 820)
self.setStyleSheet("background:black")
self.myWindow = MyWindow()
self.setCentralWidget(self.myWindow)
self.setWindowTitle("10路视频演示")
menubar = self.menuBar()
viewMenu = menubar.addMenu('显示')
self.showPoseAct = QAction('显示骨架', self,)
self.showBboxAct = QAction('显示包围盒', self,)
self.showBboxAct.setCheckable(True)
self.showPoseAct.setCheckable(True)
self.showPoseAct.setChecked(True)
viewMenu.addAction(self.showPoseAct)
viewMenu.addAction(self.showBboxAct)