from qtpy.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout app = QApplication([]) w = QWidget() layout = QVBoxLayout() layout.addWidget(QPushButton("Button 1")) layout.addWidget(QPushButton("Button 2")) layout.addWidget(QPushButton("Button 3")) w.setLayout(layout) w.show() app.exec_()
from qtpy.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout app = QApplication([]) w = QWidget() vbox1 = QVBoxLayout() vbox1.addWidget(QPushButton("Button 1")) vbox1.addWidget(QPushButton("Button 2")) vbox2 = QVBoxLayout() vbox2.addWidget(QPushButton("Button 3")) vbox2.addWidget(QPushButton("Button 4")) layout = QVBoxLayout() layout.addLayout(vbox1) layout.addLayout(vbox2) w.setLayout(layout) w.show() app.exec_()In this example, we are creating two `QVBoxLayout` instances and adding two `QPushButton` widgets in each of them. We then create a third `QVBoxLayout` instance and add the two previously created layouts to it using `addLayout`. Finally, we set the layout of the `QWidget` object to the newly created `QVBoxLayout`. Package library - `qtpy.QtWidgets` belongs to the PyQt5/PySide2 package library.