#100DaysOfCode in Python Transcripts
Chapter: Days 94-96: Rich GUI apps in Python
Lecture: Demo: Adding Gooey to our app

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now we're ready to incorporate Gooey.
0:02 So, first thing we have to do is install it.
0:04 Over here, we can say pip install gooey.
0:08 Now, this works fine on Windows and Mac,
0:10 I've found there's a little bit of a problem with Linux.
0:13 I'll show you that in a second.
0:14 But notice that it's depending on wxPython Phoenix,
0:17 which is a brand new version of wxPython,
0:20 a cross platform GUI thing, very nice.
0:23 The G-U-I version, and then Gooey is built upon that.
0:26 So while that's installing, let's look over here.
0:29 I've noticed that there's a problem installing this, and I couldn't get it to work,
0:32 so if you run these two sets of commands on Ubuntu,
0:36 at least if you're using Ubuntu,
0:38 I haven't tried it on anything else,
0:39 they should get everything set up and ready to go.
0:42 And then, you'll be able to work with wxPython
0:45 and Gooey and so on.
0:46 Without this, I couldn't get it to install.
0:48 By the way, this takes a really long time,
0:50 like ten minutes or something crazy like that,
0:52 so just be aware.
0:53 Here's the link for it over here in the Phoenix release,
0:56 the 465.
0:59 Okay, so this is all set up and ready to go,
1:01 and the other thing that we want to do,
1:03 just for completeness sake,
1:05 is we want to make sure this gets put
1:07 into the requirements file.
1:08 Partram will do that for us.
1:10 So let's say this: from gooey import GooeyParser.
1:13 We're going to need that to, actually,
1:15 that's basically the thing that triggers the UI.
1:17 We need this other thing, Decorator,
1:19 that will let us basically say run this method,
1:22 and get the parameters from it.
1:24 So we'll come over and say Gooey,
1:25 I'll say Program Name, this will be Movie Search App,
1:29 and we'll set the description.
1:31 Search, talk, Python, Demo data for movies.
1:34 Remember, this is just the search,
1:37 the movie search jacent API we've already played with.
1:40 Let's change this to the Gooey Edition here.
1:43 This is the first thing, we have to put this Decorator,
1:46 and the other, let's go to this get params.
1:48 Now all of this stuff, we don't need this at all anymore.
1:51 What we're going to do is,
1:52 we're going to create a thing called a parser.
1:54 That's going to be the GooeyParser.
1:56 Then, on the parser,
1:57 we're going to add a couple of arguments.
1:59 This is super varied,
2:00 you could have all kinds of flexibility here,
2:03 but we want to do two things.
2:04 A basic search term, and well give it,
2:07 we'll say help equals the search term, or keyword,
2:11 something to that effect.
2:13 We want another one that's a little bit more complex.
2:16 So we'll come up here and say,
2:17 dest=mode.
2:19 That's going to be the name of the parameter that comes out.
2:22 The widget, here's where it gets interesting,
2:24 this is a dropdown.
2:25 Alright, there's a lot of different type of widgets,
2:27 and our choices for our dropdown,
2:29 tell PyCharm that's spelled correctly.
2:31 That's going to be by director,
2:33 by IMDB code,
2:36 you can just say director, IMDB code,
2:40 and keyword.
2:42 Okay, so we got this and then all we need to do,
2:45 actually, keep that for one more moment,
2:47 we have to go over here
2:48 and say args = parser.args
2:50 parse args.
2:51 This actually is what triggers the UI.
2:54 And then in here,
2:56 this is a dictionary that contains two values,
2:59 search term and mode.
3:01 So we can just say return,
3:03 we return first the bottom mode and then the value.
3:06 So args.get_mode,
3:08 args.get_search_term.
3:12 this little bit of code right here,
3:16 that should do it.
3:17 Let's go ahead and run this and see what happens.
3:19 So we got our new way of getting arguments through the UI.
3:22 we've got our Gooey, fingers crossed, run it.
3:27 Look at that. How sweet is this?
3:29 See our search term right there, and this is our search term
3:32 and our mode.
3:33 So the search term is going to be Cameron again,
3:35 and this time, we're going to go down it.
3:38 Look, there's our director.
3:39 Oh, I already, I noticed something we did wrong.
3:41 This is not going to work so much here, unfortunately.
3:44 We need to change these to understand what those are.
3:48 So we could either return different values,
3:51 like if the mode is director, make it D,
3:55 or we could just put these back at the top.
3:57 I'll just change it up here.
3:58 This was not, I was just going to search under keyword,
4:01 which is not what we wanted, alright?
4:03 So this and then else it's going to fall through,
4:06 but let me just fix the comments.
4:08 You know, the comments that lie.
4:10 There we go, mode equals this. Alright, try again.
4:15 Alright, now let's go and try to find those. Ready? Go.
4:20 Oh, well I guess you can see what an error looks like.
4:22 I think, actually we don't do get. We just .mode.
4:26 It's just dynamic, it's not like a dictionary.
4:29 There you go. One more time.
4:34 Go. Boom. Look at that.
4:37 How cool is this?
4:38 That we built this Gooey application right here?
4:41 Our program exited successfully, found ten movies.
4:44 These are the ones we just saw a little bit before.
4:46 We can re-run it and it will run again.
4:48 That doesn't mean a whole lot,
4:50 it just searched the same thing.
4:52 Let's go over here and say we're now searching by keyword
4:54 for capital. Run it, and you'll see something interesting.
4:57 Notice, it put the data down here, kind of on top of it,
5:00 so there's this kind of funky weird buildup,
5:02 whereas if you run it again and again,
5:05 you get like a history.
5:06 So this is kind of just like your terminal here,
5:09 more or less.
5:10 But I think it's okay.
5:11 I mean, it's not going to win any design awards,
5:13 but it's definitely better than handing out
5:15 a command line application to somebody
5:17 who's really not into command lines.
5:20 So, a great way to sort of make your
5:22 Python application more general.