How to create a simple window in PyQt5?

In PyQt5, you can create a simple window using the QtWidgets module. Here is an example code for creating a simple window:

import sys
from PyQt5.QtWidgets import QApplication, QWidget

if __name__ == '__main__':
    app = QApplication(sys.argv)

    # 创建一个窗口
    window = QWidget()
    window.setWindowTitle('Simple Window')
    window.setGeometry(100, 100, 400, 200) # 设置窗口位置和大小 # 展示窗口


Running the above code will create a simple window and display it on the screen. The title, size, and position of the window can be modified as needed.

Leave a Reply 0

Your email address will not be published. Required fields are marked *