-
Notifications
You must be signed in to change notification settings - Fork 0
/
scrollarea_test.py
92 lines (74 loc) · 2.86 KB
/
scrollarea_test.py
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
from PyQt5.QtCore import QDir, Qt, QUrl
from PyQt5.QtMultimedia import QMediaContent, QMediaPlayer
from PyQt5.QtMultimediaWidgets import QVideoWidget
from PyQt5.QtWidgets import *
from PyQt5.QtWidgets import QMainWindow, QWidget, QPushButton, QAction, QFrame, QScrollArea
from PyQt5.QtGui import *
import sys
from PyQt5 import uic
from PyQt5 import QtCore, QtGui, QtWidgets
from PIL import Image
import os
import glob
from math import ceil
class VideoWindow(QMainWindow):
def __init__(self, parent=None):
super(VideoWindow, self).__init__(parent)
self.setWindowTitle("PyQt Video Player Widget Example")
grid = QtWidgets.QGridLayout() # Create Grid Layout
self.bg = QtWidgets.QButtonGroup(self) # Create Button Group
dir = "C:/Users/mmlab/PycharmProjects/UI_pyqt/Kate/" # Image direction
self.f = sorted(glob.glob(dir + '*.jpg'))
flen = len(self.f)
self.titles = []
self.cont01 = 0
positions = [(i, j) for i in range(int(ceil(flen / 4))) for j in range(4)]
for position, title in zip(positions, self.f):
if title == '':
continue
vBox = QtWidgets.QVBoxLayout()
QLabel = QtWidgets.QLabel()
QLabel.setFixedWidth(150)
QLabel.setFixedHeight(150)
image = self.f[self.cont01]
num = []
num.append(self.cont01)
self.qp = QPixmap()
# self.qp.loadFromData(image)
self.qp.load(image)
self.qp = self.qp.scaled(150, 150)
QLabel.setPixmap(self.qp)
vBox.addWidget(QLabel)
self.check = QCheckBox()
chk = []
for i in range(len(num)):
vBox.addWidget(self.check)
grid.addLayout(vBox, *position)
self.cont01 += 1
wid = QWidget(self)
self.setCentralWidget(wid)
frame = QtWidgets.QFrame()
# Put the GridLayout in a Widget QFrame
frame.setLayout(grid)
# Create a Widget QScrollArea()
scroll = QtWidgets.QScrollArea()
# Put the Widget QFrame in the QScrollArea()
scroll.setWidget(frame)
scroll.setWidgetResizable(False)
scroll.setFixedHeight(420)
self.scrollbar = scroll.verticalScrollBar()
# Create a QVBoxLayout
layout = QtWidgets.QVBoxLayout(self)
# Add the Widget QScrollArea to the QVBoxLayout
layout.addWidget(scroll)
wid.setLayout(layout)
def checkbox(self, num):
chk = []
for i in range(len(num)):
chk.append(QCheckBox())
# self.check.setGeometry(QtCore.QRect(10 + 100 * (i + 1), 250, 95, 95))
i += 1
app = QtWidgets.QApplication(sys.argv)
main = VideoWindow()
main.show()
sys.exit(app.exec_())