forked from docPhil99/opencvQtdemo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstaticLabel1.py
More file actions
35 lines (29 loc) · 1012 Bytes
/
staticLabel1.py
File metadata and controls
35 lines (29 loc) · 1012 Bytes
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
from PyQt5.QtWidgets import QWidget, QApplication, QLabel, QVBoxLayout
from PyQt5.QtGui import QPixmap, QColor
import sys
class App(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Qt static label demo")
width = 640
height = 480
# create the label that holds the image
self.image_label = QLabel(self)
# create a text label
self.textLabel = QLabel('Demo')
# create a vertical box layout and add the two labels
vbox = QVBoxLayout()
vbox.addWidget(self.image_label)
vbox.addWidget(self.textLabel)
# set the vbox layout as the widgets layout
self.setLayout(vbox)
# create a grey pixmap
grey = QPixmap(width, height)
grey.fill(QColor('darkGray'))
# set the image image to the grey pixmap
self.image_label.setPixmap(grey)
if __name__ == "__main__":
app = QApplication(sys.argv)
a = App()
a.show()
sys.exit(app.exec_())