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) # 设置窗口位置和大小
window.show() # 展示窗口
sys.exit(app.exec_())
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.