Splash Screens for your Pyinstaller EXE

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this tutorial I'll show you guys how to create a splash screen in your Pi installer exe now whenever you're dealing with a lot of major libraries like numpy or matplotlib or privyqt or take inter or even those machine learning and data science libraries like pytorch then your application size can get very big and load times can be between 5 to 10 seconds and that's not very good for user experience now one thing that we can do to minimize this you know this impact to user experience is to create a splash screen so that's what we'll look at in today's video how to create a splash screen now about a year ago roughly in mid 2021 I think Pi installer introduced a feature to introduce support first class screens which is a great thing because before that there was a very complicated way of doing it and for 90 of cases it wasn't even worth the effort so we're lucky we have this feature here today so let's take a look at it now here I have a very basic application it's you know using a few libraries like taking care numpy matplotlib and pandas and pandas table so this is going to be a pretty heavy application like 100 MB around and it's also gonna take about five seconds to load so we're gonna apply a splash screen to this application in today's video all right so I'm gonna you know uh just show you a little bit you can just import Exes in here sorry you can import the CSV files then plot them over here and these are just random random dots okay so that's just what this thing can do now let me just explain a few things first okay let me just uncomment this code out and explain it basically you need to understand what a frozen application is a frozen application is what we call what pi installer does Pi installer basically freezes your python environment and packages it into an exe so that's what we call Frozen applications of Frozen exes okay that's an important term now what we want to do is basically import this module that Pi installer provides us now this is a library that you do not install or download okay do not do that it won't work it's basically you know executed by and imported by pi installer whenever the exe is pressed if you try and include this in your normal code okay if you try and put this over here it's not going to work it's even giving me an error right now that you know it's not detected because it's basically linked dynamically at runtime what we want to do here is that this code should only run okay this import statement should only run if our application is being executed as an exe as a pi installer exe so this statement is basically checking to see if it's a frozen application and if yes only then it Imports it okay so that's just a useful trick you guys should know if I do this now it's going to work okay and if I if I just put it over here it would not work okay see you can see this error over here all right now this is what you do okay you just need to import this okay and there's also one more thing over here and let me just copy paste this over here first okay and let me just explain what exactly I'm doing here whoops okay now what we want to do is close the splash screen okay when you import it when you import this module it's automatically going to display the splash screen and where exactly we give the image for this that comes later okay we actually linked that later so this is actually the starting step where you import it and then you need to Define where you want to close it and where am I closing it I'm closing it in the init function of my main window so once all of this is rendered okay then I want to close my splash screen okay we could also come down here and do it or here okay we could do it over here um so there's no real problem I guess okay we can just do this over here okay to keep things simpler okay now uh what we'll do now is go ahead and generate our exe okay because this is all we have to do we just need to import it import the module and then close it once our window is done loading okay and now do whatever you have to over here all the loading stuff all loading should be done before this point any downloads that you need to do if your application is an online one do all your connections before this point okay before you close this splash screen okay now what I want to do now is open up autopi to EXE okay you can use Pi installer same thing because Pi installers and autopi to exceed you know same thing Auto Pi 2xz uses Pi installer you can actually see the equivalent Pi installer command here I'm just going to use this because it's simpler okay I'm going to select my graphing App application I'll select one file window based okay and you can see the pi installer command over here the equivalent Pi installer command and what we need to do now is come to Advanced okay and this is the splash option we come here and go to documents where I have my folder my image okay and here it is okay now if you're using pi installer in the command line then you just need to add this over here this dash dash splash then you need to put in the file path let me just extend that a bit okay then you put the file path of your image okay and remember to just keep a space okay can't I can't expand this all right there okay just keep a space over there in between now let's go ahead and convert this that's all we needed to do I'm just going to pause the video right here and we'll let this finish okay and then I'll show you guys the result all right so here we are it's complete I'll just open the output folder and where is it ah here we are the icons loading there we go okay it's a 110 MB if I if I remember correctly come on let me just okay well anyways here's here's the splash screen as you can see over here and it took about three seconds and let me just show you the size hold on okay 110 MB yeah so here's our application okay let me just do that one more time okay here's the splash screen loaded over here about three to four seconds yep so yeah and as you can see this is this works it's pretty simple now that's also a drawback because I think it's a bit too simple there should be more options uh I think this feature needs to be worked on a bit more it needs to be a bit more mature because there is an option to add text over here that I've seen people use but for some reason it just doesn't work I've tried this on multiple images you can supposedly you know put in text over here but it doesn't work for me maybe it'll work for you guys so just try that out and if this feature receives any more updates in the future I'll make sure to uh you know make a new video on that with the updated features hopefully because I am hoping this feature gets updated all right now other than that one more thing I'll mention is that for if your application is taking too long to load then you might want to look at decreasing the load time obviously so I'll have a video for that in the description below because I'm working on that right now I have a few tricks that I know of to decrease the file size to decrease the load time so we'll take a look at that okay that's all from me hope you guys enjoyed the video I know I went on a bit long but I just thought you guys needed to understand the theory behind what's going on all right see you guys in the next one
Info
Channel: CodersLegacy
Views: 4,456
Rating: undefined out of 5
Keywords: pyinstaller splash screen, pyinstaller loading screen, how to make a splash screen in python, splash screen tutorial, loading screen python
Id: sKMQpy56HSY
Channel Id: undefined
Length: 8min 37sec (517 seconds)
Published: Tue Dec 27 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.