Today, we're going to run two different experiments.
One is related to the brake statement.
So the first experiment will give you a better understanding of the brake statement.
The second experiment is related to the layout argument.
So let's begin with the first one.
This is the existing code we built so far.
So at the end of the code, we have this case as G when closed break.
Then we have winter clothes.
Now.
If I add a print buoy function just above the window, that's closed statement outside the wire loop.
You see, this is unintended.
It is in the same level with window that's close.
If I run the program now and then I press this button.
So let me show you the codes.
So if I press this button, then what do you think will happen?
So try to guess.
You see that in the command line we got by printed out.
So this function was executed.
But if I replace that with the exit function, which is a python built in function, see what's going
to happen now.
So if I run the program, so run the program again.
And close the program using that button.
This time by it's not printed out.
That is because this line is never executed.
So the difference between the break statement and the exit function is that the exit function.
Stops the program completely.
So as soon as the interpreter executes exit, then nothing else is executed.
In contrast, the break statement.
Only stops.
The wild loop from executing again.
So when the interpreter executes the brake statement, only the loop is stopped.
So there are no more iterations in the wild loop and therefore the interpreter goes and prints anything
that is outside the wild loop.
Now, your question might be should you use break or should you use exit?
And the short answer is to just use a break because it makes more sense.
So you want to break the loop in this case.
And if you want to do something else in here outside the loop, you can do so.
So the break statement allows you for better control of the flow of your program.
So you are allowed to execute other things between the the one loop and the window that's closed methods
while the exit function just exits the program completely.
Right.
That was about break.
I'll delete that to leave the code as it was before and.
The other experiment I wanted you to try.
Is related to the layout arguments.
So in our case here we are supplying this list directly in here in the argument.
So the argument is equal to its value, which is list.
But it is also possible to stall the list outside somewhere in here.
So before you create the window instance, you could first create a variable layout, for example,
and that is equal to that list.
And then in here you specify the name of that variable and that would do the same exact thing as it
was doing before when we had the list in here.
And again, you could ask, what's the better solution here?
Should you define it here in a variable first and then to the variable here or directly the list in
here?
Well, feel free to use either version, so there is no right answer here.
However, this method of defining the variable first could be beneficial when you want to dynamically
construct the list of widgets.
For example, let's suppose.
Let me type in something here.
You don't have to type this in, so I'm just typing and deleting it.
So let's suppose that you had a list of button labels, you know, just a list of strings like clothes
apply and the list could go on.
And you wanted to create a button for each of those labels.
In that case, you would want to iterate for Blue, for example, in button labels.
So you iterate over those strings.
And then above here you would say layout is equal to an empty list and then you append.
Widgets, for example, as g that button with ble as the first label.
And so this for loop would generate a layout.
Least of lists which would look like that.
Right.
And then you would supply that layout variable in here.
So in this particular case, we would end up with a layout which would look something like.
You know, as a button.
Close comma.
As a button, apply, etc. So each of those is a button instance.
So that would be the layout variable.
Yeah, I hope that's clear.
So this way you can create dynamically a layout object, which is just a list, by the way.
So it's a list of lists.
It's not any special object, but in this case we don't need to dynamically create a layout so we could
directly supply the list in here.
So I just wanted you to know that with variables, you are very flexible, so feel free to use intermediate
variables.
As I just did here.
So layout was a so-called intermediate variable.
You define it there and then you use it directly somewhere else.
And these are the two tests I want to make.
Let's move on with some more content.
So you.