The installed pyqy version is pyqt5 and I want to window appreas on screen, but it doesn't
codes :
import sys
from PyQt5 import QtGui
from PyQt5.QtWidgets import QApplication, QMainWindow
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.title = "Hello Guy!!!"
self.top = 100
self.left = 100
self.width = 680
self.height = 500
self.init()
def init(self):
self.setWindowTitle(self.title)
self.setGeometry(self.top, self.left, self.width, self.height)
App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec())
And When I run the application nothing will apear on screen.
This is because you forgot to call .show()
method of QMainWindow Class
Original Code
App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec())
Bug Fix
App = QApplication(sys.argv)
window = Window()
window.show() # this will load the window
sys.exit(App.exec())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.