15

During the startup of QGIS, there are status messages shown in the lower part of the splashscreen like "restoring loaded plugins".

I am using a startup.py feature from which I would like to inform the user which part of my startup script is executed at the moment.

Is it possible to show this information on the splashscreen?

enter image description here

Edit1:

As a workaround I managed to use my own splashscreen during startup:

from qgis.gui import *
from qgis.utils import *
from qgis.core import *
from PyQt4.QtGui import *
from qgis.PyQt.QtCore import QSettings, Qt
import time


template=QgsApplication.qgisSettingsDirPath() + "python/"
app=QgsApplication.instance()
splash_pix = QPixmap(template+'splashscreen.png')

splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
splash.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
splash.setEnabled(False)

splash.setMask(splash_pix.mask())

progressBar = QProgressBar(splash)
progressBar.setMaximum(10)
progressBar.setGeometry(0, splash_pix.height() - 20, splash_pix.width(), 10)

splash.show()

if QgsApplication.instance().findChild(QSplashScreen):
    QgsMessageLog.logMessage("ja", "gridseen", level=QgsMessageLog.INFO)
else:
    QgsMessageLog.logMessage("nein", "gridseen", level=QgsMessageLog.INFO)

splash.showMessage("<h1><font color='white'>Grid Integration-Check!</font></h1>", Qt.AlignBottom | Qt.AlignCenter, Qt.black)

for i in range(1, 11):
    progressBar.setValue(i)
    t = time.time()
    while time.time() < t + 0.1:
        app.processEvents()

time.sleep(2)
splash.close()

Therefore I put the splashscreen in my qgis-python folder (for example https://github.com/webgeodatavore/qgis-splash-screens-birthday/raw/master/resized/qgis_version_2.18.png )

enter image description here

But this solutions is a bit of a quick and dirty workaround.

Isn't it possible to get access to the splashscreen that's created during the startup of the QGIS app? I tried to get access by using QgsApplication.instance().findChild(QSplashScreen) but couldn't get access to it.

https://github.com/qgis/QGIS/blob/7bd0285dfdef9456a5929a7b7031270ea0ee2601/src/app/main.cpp#L1286

1 Answer 1

4

I figured out another solution (QGIS 3.4): startup.py

from PyQt5.QtCore import QSettings,QStandardPaths
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QLabel, QWidget, QSplashScreen,QApplication
import os

try:
    s = QSettings()
    s.setValue("PythonPlugins/BufferSelection",True)
except: pass

try:
    widgets= QApplication.allWidgets()
    for wid in widgets:
        if isinstance(wid, QSplashScreen):
            qgisAppDataPath= QStandardPaths.standardLocations(QStandardPaths.AppDataLocation)[0]
            file = os.path.join(qgisAppDataPath,"splash.png")
            if os.path.isfile(file):
                pixmap = QPixmap(file)
                wid.setPixmap(pixmap)
                app.processEvents()
            break
except: pass

It also activates my plugin, shows for a short time the original splasher (I guess, that is fair) and then the customized splasher.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.