import sys from PyQt4.QtGui import QApplication, QWidget, QVBoxLayout, QPushButton app = QApplication(sys.argv) window = QWidget() layout = QVBoxLayout() button1 = QPushButton("Button 1") button2 = QPushButton("Button 2") button3 = QPushButton("Button 3") layout.addWidget(button1) layout.addWidget(button2) layout.addWidget(button3) window.setLayout(layout) window.show() sys.exit(app.exec_())
import sys from PyQt4.QtGui import QApplication, QWidget, QVBoxLayout, QLabel, QPushButton app = QApplication(sys.argv) window = QWidget() layout = QVBoxLayout() label1 = QLabel("Label 1") label2 = QLabel("Label 2") button = QPushButton("Button") layout.addWidget(label1) layout.addWidget(label2) nested_layout = QVBoxLayout() nested_layout.addWidget(button) layout.addLayout(nested_layout) window.setLayout(layout) window.show() sys.exit(app.exec_())In summary, the PyQt4.QtGui QVBoxLayout is a layout manager that arranges widgets in a vertical layout. It is part of the PyQt4 library which is a set of Python bindings for the Qt application framework. Examples of using QVBoxLayout include adding widgets to a basic layout and nesting QVBoxLayouts to create more complex layouts.