from PyQt5.QtWidgets import QLabel label = QLabel("This is a long text that needs to be wrapped. This is a long text that needs to be wrapped.") label.setGeometry(50, 50, 200, 100) label.setWordWrap(True)
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QLabel app = QApplication([]) widget = QWidget() layout = QVBoxLayout() label1 = QLabel("This is a long text that needs to be wrapped. This is a long text that needs to be wrapped.") label1.setWordWrap(True) layout.addWidget(label1) label2 = QLabel("This is another long text that needs to be wrapped. This is another long text that needs to be wrapped.") label2.setWordWrap(True) layout.addWidget(label2) widget.setLayout(layout) widget.show() app.exec_()This code creates a GUI application with two QLabel widgets that have long texts that need to be wrapped. The QVBoxLayout class arranges the widgets vertically in the window, and the setWordWrap method enables the word wrapping for both labels. The app.exec_() method starts the application event loop.