from PyQt5.QtWidgets import QApplication, QHBoxLayout, QPushButton, QWidget # Create a QApplication and a QWidget app = QApplication([]) window = QWidget() # Create a QHBoxLayout and add two buttons with a stretch space hbox = QHBoxLayout() button1 = QPushButton("Button 1") button2 = QPushButton("Button 2") hbox.addWidget(button1) hbox.addStretch(1) hbox.addWidget(button2) # Set the QHBoxLayout as the layout of the QWidget and show it window.setLayout(hbox) window.show() # Run the application app.exec_()In this example, a QHBoxLayout is created and two QPushButton widgets are added. A stretch space is added between them to adjust their size. The addStretch function takes an integer parameter that represents the size proportion of the stretch space. In this case, the stretch space is set to 1. Package library: PyQt5.Qt.