#100DaysOfCode in Python Transcripts
Chapter: Days 94-96: Rich GUI apps in Python
Lecture: Demo: Refactoring to isolate user input

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now, before we actually add Gooey, let's just change this around a little bit so that we can have a cleaner separation
0:08 of where we get our data versus where we run it. Notice we're asking for the mode here, and then based on the mode we're doing these three things.
0:17 I'm going to come over here and make a new function, put that down on the bottom, and call this get_parameters, or get_params, something like that.
0:26 We're going to do the same thing here. We're just going to keep it the same. Instead of doing the search, we're just going to
0:33 return which thing it is that we want to do. We're going to return the mode. Let's say, yeah, return mode from director.
0:46 We're not going actually going to do the search. We're going to return the mode and the code. And finally, down here we're going to say return mode
0:55 and keyword. We can come over here and say we're going to come over here and say mode and value with the comma there. Sorry, your equals get_params.
1:08 These two values that come back are going to go here. I guess we could even put this little part down here, this little print statement.
1:16 It belongs together. Instead of doing this, if the mode is that, we're going to say we're going to pass the value over here.
1:22 Instead of doing this, we already asked that question. It stored a value. Instead of doing this, we're going to go over here and say value.
1:29 Let's just see if this runs. All right, I want to search by a director, Cameron. Seems that works. Let's try one more.
1:36 I want to search by keyword, capital. Try again. Keyword, capital. There we go. You spell it right, it works really well. Okay, so this is working.
1:47 It's nice because we just have this one function, and we get these two values back. It's this point where we can plug in our Gooey stuff.
1:55 All we have to do to create our Gooey is to add a decorator right here, and then basically tell Gooey, G-O-O-E-Y, what the parameters it's supposed to
2:06 ask for are, and how to describe them to the user. Like is this a drop down with a list? Is it a text input? Things like that.


Talk Python's Mastodon Michael Kennedy's Mastodon