Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pyinstaller adding splash screen or visual feedback during file extraction

I create a single file python application with Pyinstaller using --onefile parameters. Everything work as expected but the startup time is around 10 seconds on my machine. The problems is that during the file unpacking process of Pyinstaller package there are no visual feedback, so you don't know if the application is starting or even if you really clicked the icon. This problem became worse if the machine is slow (on my test with a very old machine i need almost 20 seconds to see the first login of my application) There is a way to create some splash screen or visual feedback (like a progress bar as on unpackers) during the Pyinstaller bootstrap sequence?

Please note the question is about Pyinstaller unpacking process BEFORE the real application will be executed not by the application itself that already has is own splash screen

thank you

19.01.2018 - UPDATE1 My application is FULL GUI so i prefer to not use the console as "visual feedback" during the unpacking process.

like image 694
Marco Avatar asked Jan 18 '18 07:01

Marco


2 Answers

There is a beta version of the splash screen!

So just use your normal pyinstaller command in cmd and add:

--splash splashfile.png
like image 115
Fabi0 Avatar answered Sep 24 '22 18:09

Fabi0


adding --splash splashfile.png gave me high pink color shades on splash screen, so I used JPG image with some colored background and it worked very well.

another update we need to close splash, within our project code in any suitable place feasible for us, else splash screen remains on top of UI until application itself is closed.

        try:
            import pyi_splash
            pyi_splash.update_text('UI Loaded ...')
            pyi_splash.close()
        except:
            pass

and put this splash screen close code with in try block as it is needed only for package execution,
and can just pass on exception and proceed at the time of development runs.

Update:

More elegant way to close the splash screen

if '_PYIBoot_SPLASH' in os.environ and importlib.util.find_spec("pyi_splash"):
    import pyi_splash
    pyi_splash.update_text('UI Loaded ...')
    pyi_splash.close()
    log.info('Splash screen closed.')

reason for discarding try/except because, if you generate console exe then try/except will unnecessarily generates warnings, so to completely avoid warnings also, this can be a good check..

like image 41
Karthik Kumar Avatar answered Sep 21 '22 18:09

Karthik Kumar