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