コード例 #1
0
ファイル: start_server.py プロジェクト: CesMak/mcts_cardgame
def initStartupProgressBar():
    splash_pix = QPixmap(300, 100)
    splash_pix.fill(QtCore.Qt.white)
    painter = QPainter(splash_pix)
    font = QFont("Times", 30)
    painter.setFont(font)
    painter.drawText(20, 65, "Loading all libs")
    painter.end()
    splash = QSplashScreen(splash_pix, QtCore.Qt.WindowStaysOnTopHint)
    progressBar = QProgressBar(splash)
    progressBar.setGeometry(splash.width() / 10, 8 * splash.height() / 10,
                            8 * splash.width() / 10,
                            splash.height() / 10)
    splash.setMask(splash_pix.mask())
    splash.show()
    return splash, progressBar
コード例 #2
0
class Splash(QObject, LogMixin, EventMixin):
    """Splash screen class"""
    def __init__(self, parent, msg=""):
        """
        Constructor of Splash screen

        :param parent: ui parent
        :param msg: initial message text

        """
        super().__init__()
        self._parent = parent
        self.isHidden = True
        self._progress = 0
        self._progressBar = None
        self.msg = msg

        pixmap = QtGui.QPixmap(380, 100)
        pixmap.fill(QtGui.QColor("darkgreen"))

        self._splash = QSplashScreen(pixmap)
        self._splash.setParent(self._parent)

        self.add_progressbar()

    def add_progressbar(self):
        """Add separate progress bar to splash screen"""

        self._progressBar = QProgressBar(self._splash)
        self._progressBar.setGeometry(self._splash.width() / 10,
                                      8 * self._splash.height() / 10,
                                      8 * self._splash.width() / 10,
                                      self._splash.height() / 10)
        self._progressBar.hide()

    def setProgress(self, val):
        """
        Set progress bar to ``val``

        If splash has no progressbar, it will be added dynamically.
        Remove progressbar with ``val`` as None.

        :param val: absolut percent value
        :return:
        """
        if val is not None:
            self._progressBar.show()
            self._progressBar.setTextVisible(True)
            self.progress = val
            try:
                self._progressBar.setValue(self.progress)
            except:
                pass
        else:
            self._progressBar.setTextVisible(False)
            self._progressBar.hide()
            self._progressBar.reset()

        if self.isHidden is True:
            self.isHidden = False
            self.show_()

    def incProgress(self, val):
        """
        Increase progressbar value by ``val``

        If splash has no progressbar, it will be added dynamically.
        Remove progressbar with ``val`` as None.

        :param val: value to increase by
        :return:
        """

        if val is not None:
            self._progressBar.show()
            self._progressBar.setTextVisible(True)
            self.progress = self.progress + val
            try:
                self._progressBar.setValue(self.progress)
                qApp.processEvents()
            except:
                pass
        else:
            self._progressBar.setTextVisible(False)
            self._progressBar.hide()
            self._progressBar.reset()

        if self.isHidden is True:
            self.isHidden = False
            self.show_()

    def setParent(self, parent):
        """Set splash's parent"""
        self._parent = parent
        self._splash.setParent(parent)

    @pyqtSlot()
    @pyqtSlot(bool)
    def close(self, dummy=True):
        self.logger.debug("Hide splash")
        self.isHidden = True
        self._progressBar.hide()
        self._progressBar.reset()
        self._splash.close()

    @pyqtSlot()
    @pyqtSlot(str)
    def show_(self, msg=""):

        if msg != "":
            self._splash.showMessage(msg, QtCore.Qt.AlignCenter,
                                     QtCore.Qt.white)
        else:
            self.logger.debug("Show splash, parent: " + str(self._parent))
            self._splash.showMessage(self.msg, QtCore.Qt.AlignCenter,
                                     QtCore.Qt.white)

        try:
            #if platform.system() == "Linux":
            parentUi = self._parent.centralwidget.geometry(
            )  # need to use centralwidget for linux preferably, don't know why
        except:
            #else:
            parentUi = self._parent.childrenRect()

        mysize = self._splash.geometry()

        hpos = parentUi.x() + ((parentUi.width() - mysize.width()) / 2)
        vpos = parentUi.y() + ((parentUi.height() - mysize.height()) / 2)

        self._splash.move(hpos, vpos)
        self._splash.show()

        qApp.processEvents()

    @property
    def progress(self):
        return self._progress

    @progress.setter
    def progress(self, value):
        # create new exception handling vor properties
        # if (value != "True") and (value != "False"):
        #    raise ValueError("describe exception")
        if value > 100:
            value = 0
        if value < 0:
            value = 0
        self._progress = value
コード例 #3
0

if __name__ == '__main__':

    game = QApplication(sys.argv)

    # Create and display the splash screen
    splash_pix = QPixmap('tiles/scrabble2.jpg')
    splash_pix = splash_pix.scaled(500, 250, Qt.KeepAspectRatio)
    splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
    splash.setMaximumSize(500, 250)
    splash.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
    splash.setEnabled(False)
    progressBar = QProgressBar(splash)
    progressBar.setRange(0, 0)
    progressBar.setGeometry(20, splash.height() - 10, splash.width(), 5)
    splash.show()

    logging.basicConfig(
        level=logging.DEBUG,
        filename='file.log',
        filemode='w')
    catch_error = ErrorWindow()
    # sys.excepthook = catch_error.excepthook

    gamewindow = None
    i = 0
    while not getattr(qffenestr.GraphicsScene, 'active_scene', False):
        if i == 10:
            gamewindow = qffenestr.MainWindow()
        i += 1
コード例 #4
0
ファイル: splash.py プロジェクト: pandel/opsiPackageBuilder
class Splash(QObject, LogMixin, EventMixin):
    """Splash screen class"""

    def __init__(self, parent, msg = ""):
        """
        Constructor of Splash screen

        :param parent: ui parent
        :param msg: initial message text

        """
        super().__init__()
        self._parent = parent
        self.isHidden = True
        self._progress = 0
        self._progressBar = None
        self.msg = msg

        pixmap = QtGui.QPixmap(380, 100)
        pixmap.fill(QtGui.QColor("darkgreen"))

        self._splash = QSplashScreen(pixmap)
        self._splash.setParent(self._parent)

        self.add_progressbar()

    def add_progressbar(self):
        """Add separate progress bar to splash screen"""

        self._progressBar = QProgressBar(self._splash)
        self._progressBar.setGeometry(self._splash.width() / 10, 8 * self._splash.height() / 10,
                               8 * self._splash.width() / 10, self._splash.height() / 10)
        self._progressBar.hide()

    def setProgress(self, val):
        """
        Set progress bar to ``val``

        If splash has no progressbar, it will be added dynamically.
        Remove progressbar with ``val`` as None.

        :param val: absolut percent value
        :return:
        """
        if val is not None:
            self._progressBar.show()
            self._progressBar.setTextVisible(True)
            self.progress = val
            try:
                self._progressBar.setValue(self.progress)
            except:
                pass
        else:
            self._progressBar.setTextVisible(False)
            self._progressBar.hide()
            self._progressBar.reset()

        if self.isHidden is True:
            self.isHidden = False
            self.show_()

    def incProgress(self, val):
        """
        Increase progressbar value by ``val``

        If splash has no progressbar, it will be added dynamically.
        Remove progressbar with ``val`` as None.

        :param val: value to increase by
        :return:
        """

        if val is not None:
            self._progressBar.show()
            self._progressBar.setTextVisible(True)
            self.progress = self.progress + val
            try:
                self._progressBar.setValue(self.progress)
                qApp.processEvents()
            except:
                pass
        else:
            self._progressBar.setTextVisible(False)
            self._progressBar.hide()
            self._progressBar.reset()

        if self.isHidden is True:
            self.isHidden = False
            self.show_()

    def setParent(self, parent):
        """Set splash's parent"""
        self._parent = parent
        self._splash.setParent(parent)

    @pyqtSlot()
    @pyqtSlot(bool)
    def close(self, dummy = True):
        self.logger.debug("Hide splash")
        self.isHidden = True
        self._progressBar.hide()
        self._progressBar.reset()
        self._splash.close()

    @pyqtSlot()
    @pyqtSlot(str)
    def show_(self, msg = ""):

        if msg != "":
            self._splash.showMessage(msg, QtCore.Qt.AlignCenter, QtCore.Qt.white)
        else:
            self.logger.debug("Show splash, parent: " + str(self._parent))
            self._splash.showMessage(self.msg, QtCore.Qt.AlignCenter, QtCore.Qt.white)

        try:
        #if platform.system() == "Linux":
            parentUi = self._parent.centralwidget.geometry()  # need to use centralwidget for linux preferably, don't know why
        except:
        #else:
            parentUi = self._parent.childrenRect()

        mysize = self._splash.geometry()

        hpos = parentUi.x() + ((parentUi.width() - mysize.width()) / 2)
        vpos = parentUi.y() + ((parentUi.height() - mysize.height()) / 2)

        self._splash.move(hpos, vpos)
        self._splash.show()

        qApp.processEvents()

    @property
    def progress(self):
        return self._progress

    @progress.setter
    def progress(self, value):
        # create new exception handling vor properties
        # if (value != "True") and (value != "False"):
        #    raise ValueError("describe exception")
        if value > 100:
            value = 0
        if value < 0:
            value = 0
        self._progress = value
コード例 #5
0
ファイル: acera.py プロジェクト: mbouskri/acera
        self.actionDocumentation.setText(_translate("aceragui", "User Guide"))
        self.actionAbout.setText(_translate("aceragui", "About"))
        self.actionCheckUpdate.setText(
            _translate("aceragui", "Check for updates"))


if __name__ == "__main__":
    import sys

    app = QtWidgets.QApplication(sys.argv)
    splash = QSplashScreen(QtGui.QPixmap("images/acerasplashshadow.png"))
    statusbar = QtWidgets.QLabel(splash)
    pal = statusbar.palette()
    pal.setColor(QtGui.QPalette.WindowText, QtGui.QColor("lightgrey"))
    statusbar.setPalette(pal)
    statusbar.setGeometry(15, 453, 8 * splash.width() / 10,
                          splash.height() / 10)
    statusbar.setText("Checking for updates...")
    splash.show()
    time.sleep(1)
    TRUE = False
    try:
        version = urlopen(
            "https://github.com/mbouskri/acera/blob/master/installer/version.txt?raw=true"
        ).read()
        if float(version) > float(__version__):
            statusbar.setText("Downloading the latest version...")
            app.processEvents()
            url = "https://www.dropbox.com/s/1opunosym7v4kj3/acera-installer.exe?dl=1"
            with open("installer/acera-installer.exe", "wb") as f:
                statusbar.setText("Downloading updates ")