def loadManager(self, methodToGetManager, *args, **kwargs): """ Show splash screen while calling `methodToGetManager(*args, **kwargs)` to get a reference to the ObsLightManager. """ pixmap = QPixmap(join(UI_PATH, "splashscreen.png")) self.splash = QSplashScreen(pixmap) self.splash.show() self.processEvents() self.splash.showMessage(u"Loading...", Qt.AlignBottom | Qt.AlignHCenter, QColor(u"white")) self.processEvents() self.__obsLightManager = methodToGetManager(*args, **kwargs) self.__logManager = LogManager(self) self.__loadMainWindow() self.__obsProjectManager = ObsProjectsManager(self) self.__micProjectsManager = MicProjectsManager(self) self.__mainWindow.callBeforeCloseEvent.append(self.__saveGeometry) self.__mainWindow.callBeforeCloseEvent.append(self.__logManager.close) self.splash.finish(self.mainWindow)
from PySide.QtGui import QApplication, QSplashScreen, QPixmap #create application and set properties app = QApplication(sys.argv) app.setOrganizationName('Chengdu University') app.setOrganizationDomain('http://www.cdu.edu.cn') app.setApplicationName('Krait') #support windows 7, 10 taskbar icon import ctypes if os.name == 'nt': myappid = 'CDU.Krait.ssr.1.0' ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) splash_img = QPixmap(":/icons/splash.png") splash = QSplashScreen(splash_img) splash.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.SplashScreen | Qt.FramelessWindowHint) splash.setStyleSheet(''' font-family:"Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; ''') splash.setEnabled(False) splash.show() def show_splash_msg(msg): splash.showMessage(msg, Qt.AlignCenter | Qt.AlignBottom, Qt.white) app.processEvents()
"pinguino_%s.qm" % sys_locale)) elif "_" in sys_locale: sys_locale = sys_locale[:sys_locale.find("_")] translations_file = "pinguino_" + sys_locale if translations_file + ".qm" in os.listdir(translations_path): translator.load( os.path.join(os.getenv("PINGUINO_DATA"), "multilanguage", "pinguino_%s.qm" % sys_locale)) app = QApplication(sys.argv) #Splash pixmap = QPixmap(":/logo/art/splash.png") splash = QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint) splash.show() splash.setStyleSheet(""" font-family: inherit; font-weight: normal; font-size: 11pt; """) def splash_write(msg): if not splash is None: splash.showMessage("\t" + msg + "\n", color=QtCore.Qt.white, alignment=QtCore.Qt.AlignBottom) splash_write(NAME + " " + VERSION)
if self.donationButton.text() == 'Donate': self.copyEthAddressButton.setVisible(True) self.copyBtcAddressButton.setVisible(True) self.donationButton.setText('Hide') elif self.donationButton.text() == 'Hide': self.copyEthAddressButton.setVisible(False) self.copyBtcAddressButton.setVisible(False) self.donationButton.setText('Donate') self.worker.start() def cleanup(self): # Clears the clipboard of any copied text clip.setText('') form = MainWindow() # Define program window # Set up and display splash screen splashImage = QImage(splashByteArray) splashPixmap = QPixmap(splashImage) splashScr = QSplashScreen(splashPixmap, Qt.WindowStaysOnTopHint) splashScr.setMask(splashPixmap.mask()) splashScr.show() sleep(1) app.processEvents() splashScr.hide() splashScr.deleteLater() form.show() app.aboutToQuit.connect(form.cleanup) # Clears the clipboard when exiting app.exec_()
class Gui(QObject): ''' ObsLight GUI main class. Keeps reference to the main window and to the ObsLightManager. ''' # signal to display a message in the status bar of the main window __messageSignal = Signal((str, int)) def __init__(self, qApplication): QObject.__init__(self) self.application = qApplication self.application.aboutToQuit.connect(self.__beforeQuitting) self.uiLoader = QUiLoader() # Need to set working directory in order to load icons self.uiLoader.setWorkingDirectory(UI_PATH) self.uiLoader.registerCustomWidget(ObsLightGuiMainWindow) self.uiLoader.registerCustomWidget(ObsLightGuiProgressDialog) # loaded in loadManager() self.splash = None self.__obsLightManager = None self.__obsProjectManager = None self.__micProjectsManager = None self.__logManager = None # loaded in __loadMainWindow() self.__mainWindow = None self.__mainWindowActionManager = None self.__statusBar = None # loaded in __createInfiniteProgressDialog() self.__infiniteProgress = None # loaded in __createProgressDialog() self.__progress = None # loaded in runWizard() self.__wizard = None def __beforeQuitting(self): """ Method called before the main QApplication quits. It disconnects the LogManager. """ self.__logManager.disconnectLogger() def loadWindow(self, uiFile, mainWindowAsParent=True, connectSlots=True): ''' Load a Window from UI file. ''' path = join(UI_PATH, uiFile) windowFile = QFile(path) windowFile.open(QIODevice.ReadOnly | QIODevice.Text) # Make all loaded windows children of mainWindow, except mainWindow itself window = self.uiLoader.load( windowFile, self.__mainWindow if mainWindowAsParent else None) windowFile.close() if connectSlots: QMetaObject.connectSlotsByName(window) return window def __loadMainWindow(self): self.__mainWindow = self.loadWindow(u"obsLightMain.ui") self.__mainWindowActionManager = MainWindowActionManager(self) self.__statusBar = self.__mainWindow.findChild(QStatusBar, u"mainStatusBar") self.__messageSignal.connect(self.__statusBar.showMessage) self.__loadGeometry() self.__mainWindow.show() def __loadGeometry(self): settings = QSettings("Intel_OTC", "obslightgui") propMap = { "mainWindow/geometry": self.__mainWindow.restoreGeometry, "mainWindow/state": self.__mainWindow.restoreState, "mainWindow/splitter2State": self.__mainWindow.splitter_2.restoreState, "mainWindow/splitter3State": self.__mainWindow.splitter_3.restoreState, "mainWindow/splitter4State": self.__mainWindow.splitter_4.restoreState, "mainWindow/splitter5State": self.__mainWindow.splitter_5.restoreState, "mainWindow/splitter6State": self.__mainWindow.splitter_6.restoreState, "mainWindow/splitterState": self.__mainWindow.splitter.restoreState, "mainWindow/splitterGeo": self.__mainWindow.splitter.restoreGeometry, "logWindow/geometry": self.__logManager.restoreGeometry } for propName, func in propMap.iteritems(): prop = settings.value(propName) if prop is not None: func(prop) def __saveGeometry(self): settings = QSettings("Intel_OTC", "obslightgui") propMap = { "mainWindow/geometry": self.__mainWindow.saveGeometry, "mainWindow/state": self.__mainWindow.saveState, "mainWindow/splitter2State": self.__mainWindow.splitter_2.saveState, "mainWindow/splitter3State": self.__mainWindow.splitter_3.saveState, "mainWindow/splitter4State": self.__mainWindow.splitter_4.saveState, "mainWindow/splitter5State": self.__mainWindow.splitter_5.saveState, "mainWindow/splitter6State": self.__mainWindow.splitter_6.saveState, "mainWindow/splitterState": self.__mainWindow.splitter.saveState, "mainWindow/splitterGeo": self.__mainWindow.splitter.saveGeometry, "logWindow/geometry": self.__logManager.saveGeometry } for propName, func in propMap.iteritems(): settings.setValue(propName, func()) def __createInfiniteProgressDialog(self): self.__infiniteProgress = self.loadWindow("obsLightProgress.ui", True) self.__infiniteProgress.connectButtons() self.__infiniteProgress.setMinimumDuration(500) self.__infiniteProgress.setWindowModality(Qt.WindowModal) self.__infiniteProgress.showCancelButton(False) # make the progress "infinite" self.__infiniteProgress.setRange(0, 0) showLogSlot = self.__mainWindowActionManager.actionLog.trigger self.__infiniteProgress.showLogButton.clicked.connect(showLogSlot) def __createProgressDialog(self): self.__progress = self.loadWindow("obsLightProgress.ui", True) self.__progress.connectButtons() self.__progress.setMinimumDuration(500) self.__progress.setWindowModality(Qt.WindowModal) # make the progress "finite" self.__progress.setRange(0, 1) showLogSlot = self.__mainWindowActionManager.actionLog.trigger self.__progress.showLogButton.clicked.connect(showLogSlot) @property def mainWindow(self): ''' Returns the main window object (may be None). ''' return self.__mainWindow def getInfiniteProgressDialog(self): ''' Get a reference to the main QProgressDialog. It is window-modal, has no cancel button and is infinite. ''' if self.__infiniteProgress is None: self.__createInfiniteProgressDialog() return self.__infiniteProgress def getProgressDialog(self): ''' Get a reference to a QProgressDialog instance. This progress dialog is window-modal and has a cancel button. ''' if self.__progress is None: self.__createProgressDialog() return self.__progress @property def manager(self): """ Get a reference to the unique ObsLightManager instance. """ return self.__obsLightManager def getLogManager(self): """ Get a reference to the LogManager instance. """ return self.__logManager def statusBarErrorCallback(self, error): ''' Display errors in the status bar of the main window. ''' if isinstance(error, OBSLightBaseError): self.sendStatusBarMessage(u"OBS Light error: %s" % error.msg, 30000) else: self.sendStatusBarMessage(u"Caught exception: %s" % str(error), 30000) def popupErrorCallback(self, error, traceback=None): ''' Display errors in a popup. Must be called from UI thread, or with a Qt signal. ''' exceptionToMessageBox(error, self.__mainWindow, traceback) def sendStatusBarMessage(self, message, timeout=0): ''' Display a message in the status bar of the main window. Timeout is in milliseconds. ''' self.__messageSignal.emit(message, timeout) def showLogWindow(self): """ Show the log window. If it is already opened, try to get it at foreground. """ self.__mainWindowActionManager.actionLog.trigger() def processEvents(self): """ Call QApplication.processEvents(). To be used if a function prevents the UI thread from returning to its event loop. """ self.application.processEvents() def refresh(self): self.__obsProjectManager.refresh() def setCurrentProject(self, projectName): self.__obsProjectManager.currentProject = projectName def runWizard(self): """ Run the OBS project creation wizard. If `autoSelectProject` is the name of an existing OBS Light project, go directly to the package selection page of the wizard. Returns the QWizard instance. """ self.__wizard = ConfigWizard(self) self.__wizard.accepted.connect(self.refresh) self.__wizard.show() return self.__wizard def runWizardToAddPackage(self, project, newPackage=False): self.__wizard = ConfigWizard(self) self.__wizard.accepted.connect(self.refresh) if newPackage: self.__wizard.skipToPackageCreation(project) else: self.__wizard.skipToPackageSelection(project) self.__wizard.show() return self.__wizard def runWizardToConfigureServer(self, parent=None, **prefilledValues): """ Run wizard and skip to server creation page. `parent` is the widget to use as parent for the wizard (None -> main window). `prefilledValues` allows to specify already known server configuration values. Possible keys for `prefilledValues`: "webUrl", "apiUrl", "repoUrl", "username", "password", "serverAlias". Returns the QWizard instance. """ self.__wizard = ConfigWizard(self, parent) self.__wizard.skipToServerCreation(**prefilledValues) self.__wizard.show() return self.__wizard def loadManager(self, methodToGetManager, *args, **kwargs): """ Show splash screen while calling `methodToGetManager(*args, **kwargs)` to get a reference to the ObsLightManager. """ pixmap = QPixmap(join(UI_PATH, "splashscreen.png")) self.splash = QSplashScreen(pixmap) self.splash.show() self.processEvents() self.splash.showMessage(u"Loading...", Qt.AlignBottom | Qt.AlignHCenter, QColor(u"white")) self.processEvents() self.__obsLightManager = methodToGetManager(*args, **kwargs) self.__logManager = LogManager(self) self.__loadMainWindow() self.__obsProjectManager = ObsProjectsManager(self) self.__micProjectsManager = MicProjectsManager(self) self.__mainWindow.callBeforeCloseEvent.append(self.__saveGeometry) self.__mainWindow.callBeforeCloseEvent.append(self.__logManager.close) self.splash.finish(self.mainWindow) def main(self): return self.application.exec_()
elif "_" in sys_locale: sys_locale = sys_locale[:sys_locale.find("_")] translations_file = "pinguino_" + sys_locale if translations_file + ".qm" in os.listdir(translations_path): translator.load(os.path.join(os.getenv("PINGUINO_DATA"), "multilanguage", "pinguino_%s.qm" % sys_locale)) if len(sys.argv) == 1: from qtgui.ide import PinguinoIDE from PySide.QtGui import QApplication, QSplashScreen, QPixmap, QPainter app = QApplication(sys.argv) #from PySide import QtGui pixmap = QPixmap(":/logo/art/splash.png") splash = QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint) splash.show() splash.setStyleSheet(""" font-family: inherit; font-weight: normal; font-size: 11pt; """) def splash_write(msg): if not splash is None: splash.showMessage("\t"+msg+"\n", color=QtCore.Qt.white, alignment=QtCore.Qt.AlignBottom) splash_write(NAME+" "+VERSION) app.processEvents()
elif "_" in sys_locale: sys_locale = sys_locale[:sys_locale.find("_")] translations_file = "pinguino_" + sys_locale if translations_file + ".qm" in os.listdir(translations_path): translator.load(os.path.join(os.getenv("PINGUINO_DATA"), "multilanguage", "pinguino_%s.qm" % sys_locale)) if len(sys.argv) == 1: from qtgui.ide import PinguinoIDE from PySide.QtGui import QApplication, QSplashScreen, QPixmap, QPainter app = QApplication(sys.argv) #from PySide import QtGui pixmap = QPixmap(":/logo/art/splash.png") splash = QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint) splash.show() splash.setStyleSheet(""" font-family: ubuntu regular; font-weight: normal; font-size: 11pt; """) def splash_write(msg): if not splash is None: splash.showMessage("\t"+msg+"\n", color=QtCore.Qt.white, alignment=QtCore.Qt.AlignBottom) splash_write(NAME+" "+VERSION) app.processEvents()
def about(self): """Popup a box with about message. Input: None Output: None""" QMessageBox.about( self, "About MClub Mover", """This program is designed to help make the process of copying \ files from multiple directories much easier and simpler.\n This software is provided as is with absolutely no warranties.""", WindowModility=True) if __name__ == '__main__': ##TODO: Look into setting caching to remember a users preference from previous execution if os_version == 'Windows': # Uberhack to make windows show my icon in the taskbar ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID( 'mclub.mover.%s' % __version__) app = QApplication(sys.argv) splash_img = QPixmap('splash.png') splash = QSplashScreen( splash_img ) # Need to see how to cleanly destroy the splash once the form is loaded. splash.show() frame = MainWindow() frame.show() app.setWindowIcon(QIcon('favicon.png')) app.exec_()
def main(): app = QApplication(sys.argv) import qdarkstyle # setup stylesheet app.setStyleSheet(qdarkstyle.load_stylesheet()) pixmap = QPixmap(os.path.join(_resourcepath('images'), "splash.png")) splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint) splash.setMask(pixmap.mask()) splash_font = splash.font() splash_font.setPixelSize(14) splash.setFont(splash_font) splash.show() splash.showMessage('Initialising...', Qt.AlignBottom | Qt.AlignLeft | Qt.AlignAbsolute, Qt.white) app.processEvents() """ for count in range(1, 6): splash.showMessage('Processing {0}...'.format(count), Qt.AlignBottom | Qt.AlignLeft, Qt.white) QApplication.processEvents() QThread.msleep(1000) """ frame = ConfiguratorWindow() frame.show_and_raise() splash.finish(frame) sys.exit(app.exec_())
app = QApplication(sys.argv) app.setOrganizationName('Bioinformatics and Integrative Genomics') app.setOrganizationDomain('http://big.cdu.edu.cn') app.setApplicationName('Krait') #set font family QFontDatabase.addApplicationFont(":/fonts/roboto.ttf") #support windows 7, 10 taskbar icon import ctypes if os.name == 'nt': myappid = 'BIG.Krait.ssr.1.0' ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) splash_img = QPixmap(":/icons/splash.png") splash = QSplashScreen(splash_img) splash.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.SplashScreen | Qt.FramelessWindowHint) splash.setStyleSheet("font-family:roboto; font-size: 14px;") splash.setEnabled(False) splash.show() def show_splash_msg(msg): splash.showMessage(msg, Qt.AlignCenter | Qt.AlignBottom, Qt.white) app.processEvents() #show_splash_msg("Loading icon resources...") import config show_splash_msg("Loading configurations...") from libs import * show_splash_msg("Loading search engines...")
# self.alpha -= 15 # if self.alpha > 0: # self.repaint() # if self.alpha == 0: # self.timer.stop() # #self.close() # def paintEvent(self,pe): # super(SplashScreen, self).paintEvent(pe) # p = QPainter(self) # p.fillRect(0,0,self.width(),self.height(), QColor(255,255,255,self.alpha)) pixmap = QPixmap(os.path.join(resource_dir,"client_splash.png")) splash = QSplashScreen(pixmap) splash.setMask(pixmap.mask()) # splash.setWindowFlags(Qt.WindowStaysOnTopHint) splash.show() splash_msg( u"{} - ".format(configuration.this_version) + _("Contacting updates server")) splash_msg( _("Loading database URL")) try: configuration.load_database_param() except Exception as e: mainlog.error(e) mainlog.error( "I was unable to get the DB URL from the server {}, so I'll continue with the file configuration".format( configuration.database_url_source)) showErrorBox( _("Can't connect to the main server"), _("I was unable to contact the main server (located here : {}). It is not 100% necessary to do so but that's not normal either. You should tell your administrator about that. I will now allow you to change the network address of the server I know in the preferences panel.").format(
handler.close() stderr_logger.removeFilter(handler) except: pass ######################################### # INITIALIZATION ## Market() # EXECUTE setup = Ui_manager(version) setup.show() splash.finish(setup) sys.exit(app.exec_()) if __name__ == '__main__': app = QApplication(sys.argv) with open(getFromConfig("path", "stylesheet_file"), 'r') as f: style = f.read() app.setStyleSheet(style) pixmap = QPixmap("./data/lancement.png") pixmap = pixmap.scaledToHeight(150, Qt.SmoothTransformation) splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint) splash.show() app.processEvents() main()
import sys from PySide.QtCore import Qt from PySide.QtGui import QApplication, QPixmap, QSplashScreen from dialog.directory_dialog import DirectoryDialog from indexer.indexer import Indexer from gui.mainwindow import MainWindow if __name__ == "__main__": app = QApplication(sys.argv) dir = DirectoryDialog() if dir.exec_() and dir.result() != "" and dir.result() != None: app.indexer = Indexer(dir.result()) splash_pix = QPixmap('res/SplashScreen.png') splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() app.indexer.load_data() app.doclist = None app.webview = None app.currentWord = None app.mainWindow = MainWindow() splash.finish(app.mainWindow) app.mainWindow.show() sys.exit(app.exec_()) else: app.quit()
dialog.setOption(QFileDialog.ShowDirsOnly) dialog.exec_() self.lblDestPath.setEnabled(True) self.lblDestPath.setText(os.path.abspath(dialog.directory().absolutePath())) self.update_table_view() self.copyButton.setEnabled(True) def about(self): """Popup a box with about message. Input: None Output: None""" QMessageBox.about(self, "About MClub Mover", """This program is designed to help make the process of copying \ files from multiple directories much easier and simpler.\n This software is provided as is with absolutely no warranties.""", WindowModility=True) if __name__ == '__main__': ##TODO: Look into setting caching to remember a users preference from previous execution if os_version == 'Windows': # Uberhack to make windows show my icon in the taskbar ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('mclub.mover.%s' % __version__) app = QApplication(sys.argv) splash_img = QPixmap('splash.png') splash = QSplashScreen(splash_img) # Need to see how to cleanly destroy the splash once the form is loaded. splash.show() frame = MainWindow() frame.show() app.setWindowIcon(QIcon('favicon.png')) app.exec_()