Skip to content

Instantly share code, notes, and snippets.

@345161974
Created March 15, 2017 12:33
Show Gist options
  • Save 345161974/c736d341477feeebf8d67176966cc98a to your computer and use it in GitHub Desktop.
Save 345161974/c736d341477feeebf8d67176966cc98a to your computer and use it in GitHub Desktop.
PyQt splashscreen demo
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import QtCore, QtGui
import time
class Form(QDialog):
""" Just a simple dialog with a couple of widgets
"""
def __init__(self, parent=None):
super(Form, self).__init__(parent)
self.browser = QTextBrowser()
self.setWindowTitle('Just a dialog')
self.lineedit = QLineEdit("Write something and press Enter")
self.lineedit.selectAll()
layout = QVBoxLayout()
layout.addWidget(self.browser)
layout.addWidget(self.lineedit)
self.setLayout(layout)
self.lineedit.setFocus()
self.connect(self.lineedit, SIGNAL("returnPressed()"), self.update_ui)
def update_ui(self):
self.browser.append(self.lineedit.text())
if __name__ == "__main__":
import sys, time
app = QApplication(sys.argv)
# create splashscreen, use the pic in folder img/bee2.jpg
splash_pix = QPixmap('img/bee2.jpg')
splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
# set the splash window flag, keep the window stay on tophint and frameless
splash.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
splash.setEnabled(False)
# splash.setMask(splash_pix.mask())
# show the splashscreen
splash.show()
# show Message
splash.showMessage("<h1><font color='green'>Welcome BeeMan!</font></h1>", Qt.AlignTop | Qt.AlignCenter, Qt.black)
# create elapse timer to cal time
timer = QtCore.QElapsedTimer()
timer.start()
# we give 3 secs
while timer.elapsed() < 3000 :
app.processEvents()
# create the main form
form = Form()
form.show()
# call finish method to destory the splashscreen
splash.finish(form)
sys.exit(app.exec_())
@345161974
Copy link
Author

the effect:
pyqt_splash_screen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment