PyQt5显示一个空白的窗口

时间:2023-03-08 16:05:40
PyQt5显示一个空白的窗口

效果如下图:

PyQt5显示一个空白的窗口

 """
In this example, we create a simple
window in PyQt5.
""" # provide the necessary imports.
# The basic widgets are located in PyQt5.QtWidgets module
import sys
from PyQt5.QtWidgets import QApplication, QWidget if __name__ == '__main__': app = QApplication(sys.argv) # create an application object
w = QWidget() # The QWidget widget is the base class of all user interface objects
w.resize(250, 150) # The resize() method resizes the widget
w.move(300, 300) # The move() method moves the widget to a position on the screen
w.setWindowTitle('Simple') # set the title of the window with setWindowTitle()
w.show() # The show() method displays the widget on the screen
sys.exit(app.exec_()) # The sys.exit() method ensures a clean exit