我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用PyQt4.QtGui.QSplashScreen()。
def showSplash(self): import pkg_resources splash_pix = QtGui.QPixmap(pkg_resources.resource_filename('PSL_Apps.stylesheets', "ipy_splash.png")) self.splash = QtGui.QSplashScreen(splash_pix, QtCore.Qt.WindowStaysOnTopHint) # adding progress bar self.progressBar = QtGui.QProgressBar(self.splash) self.progressBar.resize(self.splash.width(),20) css = pkg_resources.resource_string('PSL_Apps', "stylesheets/splash.css").decode("utf-8") if css: self.splash.setStyleSheet(css) self.splashMsg = QtGui.QLabel(self.splash);self.splashMsg.setStyleSheet("font-weight:bold;color:purple") self.splash.setMask(splash_pix.mask()) self.splashMsg.setText('Loading....');self.splashMsg.resize(self.progressBar.width(),20) self.splash.show() self.splash.repaint()
def ctmain(): utils.fix_output_encoding() settings = ComicTaggerSettings() opts = Options() opts.parseCmdLineArgs() # manage the CV API key if opts.cv_api_key: if opts.cv_api_key != settings.cv_api_key: settings.cv_api_key = opts.cv_api_key settings.save() if opts.only_set_key: print "Key set" return ComicVineTalker.api_key = settings.cv_api_key signal.signal(signal.SIGINT, signal.SIG_DFL) if not qt_available and not opts.no_gui: opts.no_gui = True print >> sys.stderr, "PyQt4 is not available. ComicTagger is limited to command-line mode." if opts.no_gui: cli.cli_mode( opts, settings ) else: app = QtGui.QApplication(sys.argv) if platform.system() != "Linux": img = QtGui.QPixmap(ComicTaggerSettings.getGraphic('tags.png')) splash = QtGui.QSplashScreen(img) splash.show() splash.raise_() app.processEvents() try: tagger_window = TaggerWindow( opts.file_list, settings, opts=opts ) tagger_window.show() if platform.system() != "Linux": splash.finish( tagger_window ) sys.exit(app.exec_()) except Exception, e: QtGui.QMessageBox.critical(QtGui.QMainWindow(), "Error", "Unhandled exception in app:\n" + traceback.format_exc() )
def __init__(self, _msg="None", _app="None", _ver="None", _link="None", _author="None"): # ------------------------------------------------------------------ self.BG = QPixmap("data/imgs/splash.png"); self.Screen = QSplashScreen(self.BG, Qt.WindowStaysOnTopHint) self.Screen.setAttribute(Qt.WA_TranslucentBackground, True); self.Screen.setMask(self.BG.mask()); self.Screen.setAttribute(Qt.WA_DeleteOnClose); font = QFont(self.Screen.font()) font.setPointSize(font.pointSize() + 5) self.Screen.setFont(font) self.Screen.show(); qApp.processEvents(); # ------------------------------------------------------------------ self.app = QLabel(_app, self.Screen); self.app.setGeometry(250, 55, 200, 45); self.app.setStyleSheet("QLabel{ color: #222; font-size: 22px; border: none; background-color: transparent; }") self.app.show(); self.ver = QLabel(_ver, self.Screen); self.ver.setGeometry(250, 80, 200, 45); self.ver.setStyleSheet("QLabel{ color: #333; font-size: 14px; border: none; background-color: transparent; }") self.ver.show(); self.author = QLabel("by: "+_author, self.Screen); self.author.setGeometry(480, 205, 120, 35); self.author.setStyleSheet("QLabel{ color: #333; font-size: 14px; border: none; background-color: transparent; }") self.author.show(); """ self.link = QLabel(_link, self.Screen); self.link.setGeometry(380, 55, 120, 35); self.link.setStyleSheet("QLabel{ color: #333; font-size: 16px; border: none; background-color: transparent; }") self.link.show(); """ self.msg = QLabel(_msg, self.Screen); self.msg.setGeometry(270, 205, 200, 35); self.msg.setStyleSheet("QLabel{ color: #333; font-size: 16px; border: none; background-color: transparent; }") self.msg.show(); # ------------------------------------------------------------------ self.Screen.update() self.Screen.repaint(); time.sleep(2); # ------------------------------------------------------------------ # =======================================================================