1
1
#! /usr/bin/python3 -B
2
2
3
3
import itertools
4
- import PyQt5 .QtCore as QtCore
5
- import PyQt5 .QtWidgets as QtWidgets
4
+ from PyQt5 .QtCore import QSize
5
+ from PyQt5 .QtWidgets import QApplication , QGridLayout , QLabel , QMainWindow , QVBoxLayout
6
6
7
7
from ScrollableContainers .Qt5 import ScrollableAreaQt5
8
8
9
9
###############################################################################
10
10
11
11
def grid_of_widgets ():
12
- app = QtWidgets .QApplication (['`ScrollableAreaQt5` demo' ])
13
- window = QtWidgets .QMainWindow ()
12
+ app = QApplication ([])
13
+ window = QMainWindow ()
14
+ window .setWindowTitle ('`ScrollableAreaQt5` demo' )
14
15
15
16
# Create a scrollable area.
16
17
scrollable_area = ScrollableAreaQt5 ()
17
18
18
19
# Add widgets to the `area` attribute of the scrollable area, not to the
19
20
# scrollable area itself.
20
21
dim = 10
21
- grid_layout = QtWidgets . QGridLayout (scrollable_area .area )
22
+ grid_layout = QGridLayout (scrollable_area .area )
22
23
for (i , j ) in itertools .product (range (dim ), repeat = 2 ):
23
- grid_layout .addWidget (QtWidgets . QLabel (text = f'Label\n ({ i } , { j } )' ), i , j )
24
+ grid_layout .addWidget (QLabel (text = f'Label\n ({ i } , { j } )' ), i , j )
24
25
25
26
window .setCentralWidget (scrollable_area )
26
27
window .show ()
@@ -29,13 +30,14 @@ def grid_of_widgets():
29
30
###############################################################################
30
31
31
32
def single_widget ():
32
- app = QtWidgets .QApplication (['`ScrollableAreaQt5` demo' ])
33
- window = QtWidgets .QMainWindow (size = QtCore .QSize (600 , 200 ))
33
+ app = QApplication ([])
34
+ window = QMainWindow (size = QSize (600 , 200 ))
35
+ window .setWindowTitle ('`ScrollableAreaQt5` demo' )
34
36
35
37
scrollable_area = ScrollableAreaQt5 ()
36
38
37
- vbox = QtWidgets . QVBoxLayout (scrollable_area .area )
38
- vbox .addWidget (QtWidgets . QLabel (text = 'big window, small label' ))
39
+ vbox = QVBoxLayout (scrollable_area .area )
40
+ vbox .addWidget (QLabel (text = 'big window, small label' ))
39
41
40
42
window .setCentralWidget (scrollable_area )
41
43
window .show ()
0 commit comments