Distributing your code with PyInstaller & PySimpleGUI | Unscripted Coding

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome back to the channel and today is another episode of unscripted coding unscripted coding for those of you new to the channel is where you get to see uh completely unscripted development there's little minimal to no planning ahead of these videos i just come up with a theme or a topic and i start trying to build something on screen there's going to be mistakes there's going to be problems if you're looking for a tutorial you're in the wrong place um today's theme is are well are these two uh really really useful pieces of software for python developers so first of all we have pi simple gui gui graphical user interface um this allows you to put a graphical interface meaning buttons input boxes text pictures um on top of your python script and the other piece of software is pi installer this one packages python applications into standalone executables so this video is really geared towards the newcomer new programmer sadly it's very much geared towards python but uh i'm sure tools are exist for things like java c-sharp that do roughly the same thing but i learned how to program on python and i've actually never used either of these two tools but they would have been a huge boost in terms of my output so let me just segue back to when i was learning the program you know you start with the very simple add two numbers multiply these numbers together and then you start getting uh more and more difficult algorithms you uh how do you flip a string backwards how do you loop how do you do recursions um and so on and for me i got super super excited about programming and i i wanted to share with everybody look at all the cool things you can do and the reality is that programming really is a super power because you only need a handful of lessons to actually do something useful so for example programming a currency converter let's say you're really just multiplying a number over times 1.3 or whatever the conversion rate is from canadian dollar to us dollar so um no the other way around us dollar to canadian dollar you multiply it by 1.3 ish um and then once you learn to loop it that's like lesson number three or four you can start doing that conversion for a hundred numbers a thousand numbers a billion numbers and you just loop through it and and uh it spits out the number beside it incredibly handy incredibly useful and it takes you know three or four lines on on python to do it so naturally i was super excited to share this to bring this to work to bring this to my friends and family and say hey look at all the awesome stuff i'm building um and you know now looking back you know they're they're very simple projects but they're meaningful projects the real problem is like most programming languages to run python you need the interpreter somebody needs to install python on their computer what these two tools do is first it gives you a graphical user interface so you don't need to command line it you don't need to write you know a run function at the end of your code um somebody can click a button okay cancel that makes it much much friendlier pi installer gets rid of the need for python it just packages it all up into a single executable so um you just double click the exe file like anything else on windows um or linux or mac or whatever else but you double click and and it runs the program boy that would have made things a lot easier to share instead you know when i was starting out i pasted it on um online interpreters so things like code sculptor so you can share that online but you know not a lot of people used it not a lot of people cared um other piece is uh well i guess the real thing is i moved into web development so that i can share these things javascript has all sorts of weird uh i will never get used to javascript but um it was incredibly handy because everybody had an internet browser on their computer you just send your html file and and there you go you have your buttons you have your boxes you have your javascript code all ready to run on a phone on a tablet on a computer anywhere so that was the big big big big advantage of web development but um i never really forgot about python i i love the language i love working with python it's just so easy it's just so readable and clean to me and so um i'm very excited to try uh these two tools to see what we can build okay so when i started this video i didn't really know what exactly i was going to build i i knew i wanted to use pi simple gui and pi installer but was i going to build a currency converter was i going to build you know nuclear bomb i i didn't really know um but came across poke api you guys saw me look through it i've seen this api before and so um it was really really interesting well it's interesting because i know that uh today well not today but this year is the 25th anniversary of pokemon uh can you believe it 25 years of this franchise so uh it might be cool to build like a really simple application and so this poke api looks like it's it's well thought out and and pretty robust so if we want a list of pokemon we just go and look they do have a limit of 20 and up of how many pokemon you can uh see at a time then you kind of offset it so in this case limit 100 means you want a list of 100 pokemon offset 200 means you start at 201 so um unknown is pokemon 201 and if you take that number um you can find out more about that pokemon so here oh this brings back memories um you have their abilities you have their moves you have you know height id location encounters that's really useful but um i'm not planning to build like a super sophisticated piece of software like the point of this is to demo uh a graphical user interface i'm packaging this up but um this is pretty cool sprites um okay so having sprites means that we might be able to put some images into into our application as well so that's a really tiny looking um image but uh nevertheless you know you don't want a nobody wants to see a program that's just buttons and texts and um i'm you know truthfully i don't think well we're not going to make a very nice looking graphical user interface like people spend years and years trying to polish and make a really great user experience um and the other thing is simple gui the point is to have a very simple uh and quick graphical user interface there are other uh user interface um packages for python that will give you more options to make it look really nice to make it more polished but you can see like ours is going to look something like this where it is not not that nice looking so um yeah uh so i just wanted to let you guys know what exactly we're going to be building and um let me just get right back into it [Music] do [Music] [Music] [Music] [Music] do do [Music] [Music] [Music] so [Music] [Music] um [Music] okay so we are getting quite close here um to a reasonable application you have you know all 1100 or so pokemon and then if you click i just love these like first 150 i mean who doesn't have great memories of like pokemon red and blue so you know king um i i will have to say like you can very easily pull more information and and put it down here that's not the point of this video and so you'll you can easily put all of their abilities you probably want to do nice fonts and all of that to make it really nice but um that's not the point here we just want a very simple demonstration uh it's actually very very quick to build this out um let me just run through this line by line for you guys well not line by line but uh let's see where we are so um you gotta work your way backwards because they they want you to start with the smallest like the smallest details up front so these columns these list boxes and then you work your way all the way down to the window it's it's a bit strange it actually reminds me a little bit of flutter but uh the syntax you'll have to get used to it a little bit and um the idea is really simple you have these basic components so you have the title the text uh images and you also have this handy list box that's probably a more complicated um widget or component and then you can start grouping them up so we have this left column we have this right column we have this footer and then we have this layout which eventually wraps its way into a layup and so uh into the window the the full window now the layout is probably the best way to show this you have um that you have these lists within a list of layouts so the layout will list a series of lists and each of those lists uh is is a row basically a row going left to right and so the first item on that list shows up right at the top so we have a list of a single item which is the title pokemon select then we have another list here which is the left column then the right column which we've packaged into their column format but i don't think that matters um and and that goes from left to right very intuitive and then we have the footer at the bottom and so um if i want to change this footer and i think it looks a bit odd right now i can just move these components in here instead so uh let's say i want this github beside the close button in the same row uh i i have a github and and the close button should probably be anchored to the left so let's just move it here get rid of this footer piece and we restart and there it's exactly as you expect um mind you pie simple gui like you don't have a whole lot of customization options you are going to run into i wish i could make this button look better i wish i could change um you know nudge this left and right a little bit like a web page or something but it's really not designed for that it's really designed for quickly getting a window together and now that i know how this works and i get the syntax i think this will be super duper quick to do um and then and then here we have the looping and so the looping does two things you have events where you can click buttons or uh close the window and i've just stolen this from the demo and then you have values which also get updated over time if you have input boxes or you're clicking items in this list box you're changing the values and what we're doing here is looping over and over while true every time the event or values change we we start updating this so um well for values it's not even doing that it's just changing every time every time it's looping through this window name so over here charmeleon is updating according to the input value so and then now that's changed to blastoise the name changes and then we do this over and over and over um i realized this now that this is probably not the best place to put this request since we're pinging it over and over so let's just stop that um so this code is not a shining polished beacon of great code you should be packaging all of this into a function so i imagine this should go into like a main function as well but uh i i will probably change this off screen because i don't want to hammer the poke api uh over and over needlessly so the next step is to package this all up with pie installer now normally this is like a 10 second job um aware i think it'll be very interesting and i don't know how i'll handle it is that we're writing these files so i i'm writing onto the folder a sprite.png file to to display it can't um simple gui just can't display a url uh image you need it somewhere on your computer and that uh was a challenge so i had to save it onto a computer and then post it back up i don't know how pi installer will handle it hopefully it will just very smoothly you know put it beside where the the executable is or something along those lines so uh i'm just gonna stop talking we'll see how that goes [Music] [Music] [Music] i got good news everyone um it's working now you'll notice that there is a jump between you know the last footage and now and i will explain that in a second but i just wanted to show you when i run this um it puts out a console kind of uh page and then you have your application now the console is because i put the dash c command you can remove that and then all you get is this this beautiful um uh window for you that's the only thing that i'd pop up so it looks really really good um it works of course now thinking back uh i really enjoyed using simple gui uh i obviously had a bit of adjusting to do and i had to read and figure out how to use it but it's very elegant it's very simple and you know it's it's a serviceable interface i i admit you know you can definitely do a lot more polishing you can definitely make it look nicer but for somebody building you know a currency converter somebody's showing some very simple uh scripts this is more than enough all you need is some place to print out text and buttons to close and maybe an input so that has been excellent pi installer i obviously struggled with it the reason is because and i think it's because i have multiple versions of python running on this computer uh and and what's happening is it couldn't pull the tk inter files into the executable and i think the problem is it's trying to figure out uh where it's pulling from and in the end it just didn't put it in at all so what i did was i just installed it onto my surface in front of me that has a clean just 3.6 running and you just pip install and then you run the one command and and it spits out your file so it could not be an easier process as well pi installer i i highly recommend as well it it is it's two lines two commands and and you get your file so uh i think i wish somebody had shown me this when when i started out because um i'm i'm that annoying guy that wants to share with everybody what i built and um i guess i'm still doing this now it really sucked to share you know just raw code nobody understood that nobody you know what does that mean what does this do um but if you have a really simple interface right here you can turn your simple you know um rock paper scissors or your simple coin toss application into something that people can see and and share so uh that's that's all there is to it um you can obviously make this a better application you can pull more information in here we're not like that wasn't the point the point is there's a very easy way to to compile this all together and share it and it works remarkably well uh pairing simple gui and and pie installer really really an excellent combo and so i hope all of you guys are inspired to start sharing your applications because you know even the simplest applications it doesn't take very many lines five ten lines of code can actually become a really useful file oh and that reminds me of the worry that i did have and please remember this is not really polish code there's all sorts of problems with it but i'm really pleased that i can still fetch this sprite file and put it in here so that didn't pose any problem for pi installer whatsoever um it just runs along the side here and then we we change uh images uh i'm i'm jumping all over the place but uh hopefully you guys enjoyed this video if you liked it thumbs up um if you didn't please leave a comment um i i am happy to take feedback and uh if if you liked it i i also take feedback for future episodes future kind of tools that we can tinker with or ways we could have improved this project i do have some really awesome videos upcoming so um you know do subscribe if you enjoyed this video i think um maybe not the next video but i do have a few videos down the line that i'm very excited to share with you guys um and that's it so thanks for watching
Info
Channel: Unscripted Coding
Views: 785
Rating: 5 out of 5
Keywords: program, programming, code, coding, project, tutorial, how to, python, walkthrough, pysimplegui, gui, user interface, graphical, package, exe, executable, deploy, desktop, app, pyinstaller, py2exe, distributing, distribution, install
Id: iipM3Smzmm4
Channel Id: undefined
Length: 26min 2sec (1562 seconds)
Published: Fri Mar 12 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.