#100DaysOfCode in Python Transcripts
Chapter: Days 94-96: Rich GUI apps in Python
Lecture: Demo: Refactoring to isolate user input
0:00 Now, before we actually add Gooey, let's just change this
0:03 around a little bit so that we can have a cleaner separation
0:07 of where we get our data versus where we run it.
0:11 Notice we're asking for the mode here, and then based on the
0:13 mode we're doing these three things.
0:16 I'm going to come over here and make a new function,
0:19 put that down on the bottom, and call this get_parameters,
0:23 or get_params, something like that.
0:25 We're going to do the same thing here.
0:27 We're just going to keep it the same.
0:28 Instead of doing the search, we're just going to
0:32 return which thing it is that we want to do.
0:35 We're going to return the mode.
0:38 Let's say, yeah, return mode from director.
0:45 We're not going actually going to do the search.
0:46 We're going to return the mode and the code.
0:49 And finally, down here we're going to say return mode
0:54 and keyword.
0:56 We can come over here and say
0:59 we're going to come over here and say mode and value
1:03 with the comma there.
1:04 Sorry, your equals get_params.
1:07 These two values that come back are going to go here.
1:10 I guess we could even put this little part down here,
1:14 this little print statement.
1:15 It belongs together.
1:16 Instead of doing this, if the mode is that, we're going
1:18 to say we're going to pass the value over here.
1:21 Instead of doing this, we already asked that question.
1:23 It stored a value.
1:24 Instead of doing this, we're going
1:26 to go over here and say value.
1:28 Let's just see if this runs.
1:29 All right, I want to search by a director, Cameron.
1:33 Seems that works.
1:34 Let's try one more.
1:35 I want to search by keyword, capital.
1:39 Try again.
1:40 Keyword, capital.
1:42 There we go.
1:43 You spell it right,
1:44 it works really well.
1:45 Okay, so this is working.
1:46 It's nice because we just have this one function,
1:48 and we get these two values back.
1:50 It's this point where we can plug in our Gooey stuff.
1:54 All we have to do to create our Gooey is to add
1:56 a decorator right here, and then basically tell
2:00 Gooey, G-O-O-E-Y, what the parameters it's supposed to
2:05 ask for are, and how to describe them to the user.
2:11 Like is this a drop down with a list?
2:13 Is it a text input? Things like that.