I am trying to create a GUI application in python using PyQt5 and wanted to implement splash screen in it. The problem is that after hiding the splash screen image I add a button to the same QWidget and call update() but it isn't showing.
Code
import sys
from PyQt5.QtWidgets import QApplication, QLabel, QWidget,QPushButton
from PyQt5.QtGui import QCursor,QPixmap
from PyQt5.QtCore import Qt,QTimer
class classer:
def __init__(self):
self.w=QWidget()
self.w.setFixedSize(640,480)
self.w.setWindowTitle("Classer")
def splashScreen(self):
img = QLabel(self.w)
img.setGeometry(0,0,640,480)
pixmap = QPixmap('SplashScreen.png')
img.setPixmap(pixmap.scaled(640,480,Qt.KeepAspectRatio))
self.w.show()
QTimer.singleShot(2000, img.hide)
def mainScreen(self):
btn=QPushButton(self.w)
btn.setText('Click')
btn.move(270,228)
btn.setCursor(QCursor(Qt.PointingHandCursor))
self.w.update()
print("reached here!")
def run(self):
self.splashScreen()
self.mainScreen()
sys.exit(app.exec_())
if __name__ == '__main__':
app = QApplication([])
app.setStyleSheet(open('StyleSheet.css').read())
instance=classer()
instance.run()