#100DaysOfCode in Python Transcripts
Chapter: Days 94-96: Rich GUI apps in Python
Lecture: Demo: Packaging our app for redistribution

Login or purchase this course to watch this video and the rest of the course contents.
0:00 So, we've seen that we can run our app, and let's actually run it over here. We could go to somebody and say, all right here's what you need to do
0:08 to run our little program. You have to create the virtual environment and then you have to activate the virtual environment.
0:14 They have to pip install the actual requirements. Once that's all set up, you can Python your program, and whew, it runs, finally.
0:25 Okay, so that's not really the way you want to hand out a general application, is it? You want to say, here, double click this.
0:32 It looks just like your Firefox, or your Word, or whatever application people are used to working with. So, we're going to use a program,
0:39 or a utility, called PyInstaller. So, over here, the first thing have to do to use PyInstaller, is install it.
0:51 Now, PyInstaller works on all of the platforms, so that's really nice, and the easiest way to run it is to create a file called build.spec.
1:01 And if you go to the PyInstaller page, it'll say, here's an example one. So we're going to do, basically, grab this.
1:11 I'm going to grab some text, basically, that I got from there, other than I put in the name, so you can see like
1:16 right here, Movie Search App is the name. But it does things like, don't you have the console, make it windowed, things like that.
1:24 And the other thing it needs is the Python path, so I'm going to say, which Python, with my virtual environment activated.
1:31 So in that case, we're going to use this great long one there, okay. That should pretty much be it. Go through, set the name of your application
1:42 and things like this. So once this is here, we can come over here, and we can, in our terminal, either one will do,
1:49 we just say PyInstaller, let's do it over in this bigger one, 'cause you'll see all the stuff that comes out.
1:54 So again, the virtual environment is there, this build spec is here, so we'll say PyInstaller ... So PyInstaller build.spec.
2:08 It's done. It's completed successfully. How awesome it that? That took a moment, but let's go see what we have in here now. Just minimize everything.
2:15 And now, in our final search app, we have a build folder, which is kind of a temporary working directory
2:19 and it will be quicker if you rerun the PyInstaller based for that stuff is there. But this is what we care about. Look at this.
2:26 This one .app file, put it over here. Now, what happens if I double click it? Wait for a second. And there's our UI. Let's go search for something.
2:37 I'm going to search for "action," and this will be a general keyword. Boom, there are eight movies, the action in it.
2:44 So, Last Action Hero, Looney Tunes: Back in Action, Civil Action, things like that. How cool is that? Now, you may notice this
2:51 little thing back here, this terminal. That is actually what I would call not cool, so I'm going to close that.
2:57 Now, if I go over to my Windows virtual machine, and I run the exact same process. I pip install, I run the requirements,
3:04 and then I pip install, PyInstaller, and I run PyInstaller build.spec, I will get a single .exe, and that single exe will run just like we saw.
3:15 But it has no command prompt. It literally runs as just a Windows application. If I do the same thing on the Linux
3:20 after I get the funky stuff to install with Aptitude, then I run the PyInstaller, I get this to show the Gooey, no terminal.
3:28 For some reason, I think it's a minor bug with PyInstaller that this is shown, even when I'm in the command thing. We told it not to, but still,
3:37 the benefit of having a thing I can double click right here, and that Gooey comes up in Python, that is really sublime.
3:45 And the fact that this is all bundled up. I literally just compressed this .app and I send it around. There's no dependencies. Even better.
3:52 So, I really hope you like this ability create a Gooey and then package it up for reuse, because I think that really broadens the reach
4:00 of what you can do with Python. Now, these are not super, super general applications that you've seen. There are some nice examples.
4:07 If we go to the Gooey page and we scroll down here, scroll, scrolling, you see some nice examples, even at the bottom, I think there's some here.
4:14 Yeah, you can see tabbed groups, custom groups, sidebar navigation, all kinds of stuff going on here.
4:20 But what I want to show you is, if you go to the examples, there's actually a different repository with a bunch of different examples.
4:28 Success screen, error screen, flat versus column layout, all that kind of stuff. So you can go over here and play around with those,
4:34 just even like a dynamically generated one. So, you can do a lot, but you can't build entirely general applications.
4:41 This is a quick way to turn command line apps into rich Gooey apps, and I think it does it really well.

Talk Python's Mastodon Michael Kennedy's Mastodon