# Import required packages from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel # Create a new window app = QApplication([]) window = QWidget() # Create a QVBoxLayout widget layout = QVBoxLayout(window) # Add a label widget to the layout label = QLabel('Welcome to PyQt5') layout.addWidget(label) # Show the window window.show()
# Import required packages from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton # Create a new window app = QApplication([]) window = QWidget() # Create a QVBoxLayout widget layout = QVBoxLayout(window) # Add button widgets to the layout button1 = QPushButton('Button 1') button2 = QPushButton('Button 2') button3 = QPushButton('Button 3') layout.addWidget(button1) layout.addWidget(button2) layout.addWidget(button3) # Show the window window.show()In both examples, we have used the PyQt5 package library to create a window, a vertical layout (QVBoxLayout), and various widget types such as QLabel and QPushButton. We have used the addWidget method of the QVBoxLayout class to add these widgets to the layout.