Hi.
Today, you're going to go deeper into understanding how desktop computer programs actually work and
how to make them.
Exactly.
We're going to do two things today.
First, we're going to make this window bigger.
All the phones, all the buttons, the text boxes, it's going to look bigger.
And then the second thing is we're going to implement this add button.
So if the user.
And to say to do here and they press a button that to do item is going to be stored in the to those
that text file.
So let's do this.
This window, as you know, is it is produced by this guy, that P file.
For those who are using it, make sure that if you click on Get here on this tab.
Make sure that these two.
Tags are set.
On the latest commit.
So if one of these texts is in the previous commits, then you want to right click here and then go
to.
Check out and then check out Monster.
In my case, this is fine, so I'm not doing anything.
In your case, I also suppose this is also like this.
But if you have been playing around with checking out different commits, you might have forgotten and
you might be checked out in a previous commit.
So you want to be checked out in the latest commit.
So you have the latest version of your program that makes sure that we are actually developing the latest
version of the program and not a previous version.
Let's begin.
Go to window, which has this argument, this other argument.
So it has two arguments.
Currently, we're going to add a third argument.
So go to the end here.
So just before the closing parentheses, you want to put a comma and then you should say font is equal.
To to to pull maybe a space here, remove that space.
So this to pull.
Shoots contain two elements a string which should specify a font family and a font size, which should
be a number.
So 20 I think is fine.
A size of 24.
The phones know what I'm going to do actually is.
I'm going to have these arguments each in one line.
So after my To-Do app and after the comma just here, after the space coming, after the comma, I want
to press enter to split that line into multiple lines.
And that is syntactically fine.
And I'll do the same for the other arguments.
So before phones, I want to split it.
I'm doing this because this line is getting too long, so it's better to have.
Around 79 characters for one line.
So that is the recommended length of Python code line 79 mins one, two, three, four, five, six
and so on up to 17.
That's a recommended size unless you have a good reason not to keep that recommendation.
For example, when I'm doing videos here.
I'm interested to show you as many lines of code as possible.
Therefore, I can let some lines be longer horizontally, so that I can show you more lines vertically.
But generally the recommendation is 79 characters.
The reason for that is to also be able to show several files in a split view.
For example, if I right click over functions and I open it in the right split and so I am able to see
both.
Files by keeping that 79.
Long character limit.
So that's the idea.
Let me close that.
We don't need to see it right now.
So let me run the code.
Gooey dot pie.
And that's the output.
So it's looking better.
Next.
This is what we're going to do whenever the user enters something here, like buy grocery and we press
ads, we're going to store that into those that text.
What happens to it when we press add to right now, this is what happens.
Everything under the reeds is executed.
So what is the window that reads anyway?
So this is a methods, but usually methods.
Return something.
Not all the time, but this method does return something.
So let's store that output in a variable.
Let's call this variable event and then I'm going to print out the event variable down here and I'm
going to run the code again.
Let's say.
Just try to keep it short.
And we've got something.
So it's a tipple.
You see, it's wrapped in parentheses.
So any instance, wrapped in parentheses is a tuple.
Well, these are not tuples, by the way, so that those are parentheses for instances or functions.
So when the parentheses are.
Connect it to a name that is not a tuple when the parentheses are individual such as This one's in here
so they don't have a name in here.
That means that is a tuple.
This table contains one item here and another item in here.
This first item is the label of the button, and this other item is a dictionary.
It contains zero as the key and high as the value.
High is what we entered in the textbooks.
And zero is the key of how actually we can change the zero.
If we go to the input box.
Instance.
And we add another argument here.
So after tooltip, we add key is equal to let's say to do, let's run again, run right high again,
press adds.
So now you see that to do is the key of that.
So basically what we got here is information about the event that happens.
The event was, as you saw, getting a value in the input box and pressing the button.
So that's what we get here.
We get the first one, which is the label of the button and then the information about the input box.
So it says that to do input box, input text instance was having a value and that is the value of that
instance.
So this allows us now to get these two values and store them into those the text.
But a better way to have this variable is to actually create two variables events and values.
And then print event first and then print values and see what's going to happen.
Let me let me stop it, because it's not showing and run again.
Sometimes you have to quit the app among your programs and run again.
Right.
Let's try high again, press ads and we get ad for the event and this dictionary for values.
So basically what we did here is x Y, which is creating two variables in one single line, and then
we have a tuple with two elements.
So one element first and two elements.
And so X will get the value of three and.
Why will get the value of four.
So same happens in here.
Event gets the value of add the first item of that tuple and values.
Get the the value of this dictionary because actually.
The press of a button is an event.
So event is getting the label of the button which was pressed.
And the values variable is getting the values that were filled by the user.
So now you know that it is possible to assign two variables at the same time to a tuple or a list which
has that number of items.
So two variables, a table with two items or at least with two items, etc..
Now the next problem we need to solve is the program.
Closing.
When we press that add button, we don't want the program to be closed, so let's fix that.
Well, the easy way to fix it is to add a while loop while true and just indent that.
Read the method under the true loop.
Let's also indent print events and print values under the wild loop, but don't indent a window that
close.
The window is closed on after the wild loop ends.
So let's check now around high add.
We get the print thing here, right?
But the window is still open.
It didn't close, so you can keep on using your program as the user press adds.
Again, it says that the add button was pressed and this halo value was received from the two two input
box.
So to do is the IDs of that input box.
It is how the program identifies that instance now, and that's why we set here to do so.
Whatever value you give here, it's going to be shown in here and that is the wild loop which keeps
the window.
Open.
So it reads It's over and over again.
Every event that happens creates another run of the loop.
So therefore what true is always true.
Therefore, the loops will will happen over and over again.
And now we ready to add some match event case add and do something if we have a net case for event.
So you see that any time we had an event printed out ad and so on.
And later on we're going to add more buttons such as an edit button.
So we might save an edit event and complete the button.
We might have a complete event.
Therefore, we're going to have match events in case it is an ad event.
Do something.
In case it is a an edit event, do something else.
And so on.
So if it is an ad event.
We're going to get the two dudes from the functions module, which I'm importing up here.
So import functions and then functions that get to dos.
We'll.
Let me split this on the right.
We'll call this function.
And that function gives us the list of the to dos.
So this function reads that to dos the text file and gets that list.
From there and returns it to us.
So to do so is going to be equal to the list of the to dos.
Now, in this file path, I have this to do underscore item.
I'll change it to to do the text to reflect more to do the text file.
So make sure you have that right as well in your computer.
So once I have to dos.
Then I say to dos that.
Append to add the new to do, but which is the new to do?
Well, the new to do.
Is values.
To do so.
Values is this variable and that variable represents this dictionary.
And with that syntax values to do, we get that high value.
So we get the value of the to the key.
So this is a dictionary of a key and the value and values to do gives us that value over to the key.
Right?
Then we append new to do to the to this list.
And then functions dot right to dos.
So I'm calling that function which expects this to those arguments.
So that's a to do lists this list now which has this new to do add it on top of it at the end of it
actually.
So the new list is going to be written in the file.
Here.
Be careful.
You might want to add.
Plus.
Backslash n a brick line.
So the user answers that to do without a brick line.
Therefore, we want to add a brick line so that each To-Do is in a separate line and that's it.
So let's try this round.
Gooey.
I had to close to quit the program first and run it again.
Let's say massive python ad we get this printed out and that's one as well.
So let's check to do the test now.
And here we go.
Master Python is part of the to do list.
So it's working.
Now, let me bring back the program.
If I press this button, you're going to see this errors.
So maybe it won't kill the application and we want to fix that error now.
So go again to go with that pie.
And what you want to do is add another case.
So case which is indented in the same level with the other case.
Add here is this one is going to be as g that when.
Closed.
So what is as G and what is when closed?
Well, as is the module pi symbol goody and window close win close.
If you right click here and go to implementations, you're going to see that this is a variable defined
in the pi symbol files.
So this variable is then used somewhere else in here.
And this variable is going to get some dynamic values which specify if the window is closed or not.
So if that is the case, if this gets a true value, then we want to break the while loop.
So break is a statement related to the wild loop.
And this case happens when we press.
That rat's bottom.
So when we press the button.
Then we don't get to that error anymore.
So the program finishes correctly.
Later on, we're going to add an exit button as well, so we can use that exit button also to close
the program.
But for now, let's just use this button.
So that is the final program.
I want to commit my changes now.
So everything looks okay.
It's working.
Therefore I want to go to the git commit button up here.
Press that button and you want to create a new commit message.
So what did we just do?
What did we develop?
Was it a new feature?
Was it some changes?
Well, we added a new feature.
We implemented.
The ads button.
So press commit.
And then you can also do a push.
Operation.
I get pushed to upload your changes, your files to get help to synchronize your project with GitHub.
But I usually do this by the end of the day once I have done several commits.
So I wouldn't do this now.
We have one more video to go.
So after that video we can do a push to GitHub.
So with that, thank you for following.
See you later.