import sys from PyQt5.QtWidgets import QApplication, QLineEdit app = QApplication(sys.argv) line_edit = QLineEdit('Hello World!') line_edit.adjustSize() line_edit.show() sys.exit(app.exec_())In this example, a QLineEdit widget is created with the text "Hello World!". The adjustSize method is called to resize the widget to fit the text. Package library: PyQt5.QtWidgets