-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples_ScrollableAreaQt6.py
executable file
·51 lines (37 loc) · 1.49 KB
/
examples_ScrollableAreaQt6.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
#! /usr/bin/env python3
import itertools
from PyQt6.QtCore import QSize
from PyQt6.QtWidgets import QApplication, QGridLayout, QLabel, QMainWindow, QVBoxLayout
from ScrollableContainers import ScrollableAreaQt6
class ExamplesScrollableAreaQt6:
def __init__(self):
self.grid_of_widgets(QMainWindow())
self.single_widget(QMainWindow())
def grid_of_widgets(self, window):
self.win1 = window
window.setWindowTitle("`ScrollableAreaQt6` demo")
# Create a scrollable area.
scrollable_area = ScrollableAreaQt6()
# Add widgets to the ``area`` attribute of the scrollable area, not to
# the scrollable area itself.
dim = 10
grid_layout = QGridLayout(scrollable_area.area)
for i, j in itertools.product(range(dim), repeat=2):
label = QLabel(text=f"Label\n({i}, {j})")
grid_layout.addWidget(label, i, j)
window.setCentralWidget(scrollable_area)
window.show()
def single_widget(self, window):
self.win2 = window
window.setWindowTitle("`ScrollableAreaQt6` demo")
window.resize(QSize(600, 200))
scrollable_area = ScrollableAreaQt6()
vbox = QVBoxLayout(scrollable_area.area)
label = QLabel(text="big window, small label")
vbox.addWidget(label)
window.setCentralWidget(scrollable_area)
window.show()
if __name__ == "__main__":
app = QApplication([])
examples = ExamplesScrollableAreaQt6()
app.exec()