Hello and welcome to the part two of creating a digital clock using Python.
In this part we are going to build the user interface.
So we start by typing in route and we said that two equals two.
T.K.
the T K basically creates the root.
Everything that you put on your screen whether it is a text box a button or an image is known as a widget
and they must all be placed in the root.
So the roots is kind of like a basket that you put all your widgets in.
So let's add some more to this root next and want to do is set the attributes.
So I do root dot attributes
and inside of things I'm going to specify the attributes someone set the value for for screen.
If you want your application to display in full screen then you set the value to true when it's full
screen you can.
It's hard to resize it.
So I'm going to set that to force what you want to also be full screen where it can be resize and you
can set it to true.
I would you know just play around with it and see what set it to force code to make it easier for you
to resize it to your taste.
I want to set the background color for the clock on a send it to black.
So you do root configure called FICO and then a parent sees you typing in the word background
and you set it to whatever color you want.
I'm going to send it to black typing black make sure you always match up your quotes.
Next thing I wanted to I need you to be able to click on the X button.
You can see this X here on or create one for the application so that you can exit when you click that
sort of root and bind.
So I'm going to bind I'm going to bind this function here called quit.
So I'll wrap that in parentheses so attach a label called X and that X. I'm going to also parsing the
function called quit.
So this root or bind will take in two arguments these value x and then quit.
This is the functional already defined.
I'm going to trigger the clock again to start to do a root dot after every milliseconds.
I want the clock to start.
So call the clock on this core function which is clock on this code time and that trigger the clock
to start and call this variable this here and I'm sending that to a string variable function in order
to save time.
I have completed the code so let me just go through what I added on.
So here I've created a variable called F.A. and said that two equals two font font.
So basically I'm using the specified a font family here called Helvetica.
And I've said that the size of the font to be a hundred and twenty the weight.
That means I wanted to be bold.
And here I have defined this text to 60 variable and I've set that to equals to a string var what this
means is that this will hold a string value by default.
OK.
And here I am using the this LBO.
It's a label variable and I'm using reference in this T T K which is sub module of T counter.
So here is where we are setting the properties for the clock.
So we sat in the background which is the foreground color of the clock is going to be white while the
background of the actual clock.
The text is going to be blank.
This is different from this.
This is this relates to the screen.
This week of setting these properties here.
These settings of the actual window while these ones here are for the actual clock itself.
The text that the clock displays that's what these settings are for.
That's the foreground color and that's the background color.
And this here is used to anchor it to the center here.
I've used the relics and the rely basically these are geometric functions in t Kenta who basically use
them to give a position that is relative to the window Wow.
The uncle here.
He's used to naturally center the widget.
Finally on this line here was the route the main loop.
This basically handles the tea into event loop.
So basically it keeps the application or the clock running on till the window is closed.
So that is it.
So the clock is basically built more.
I would advise you to make sure you format those options here to format you can indent make sure your
indentation is like mine because this edit was quite very fuzzy.
So if you don't intend things properly it will complain.
So make sure your indentation is spot on.
If you get any errors usually the arrows would be on this side in the shell just response to it.
Okay so I'm just gonna click save.
Now I want to run the clock so you can run it by just query run and click on module and I will open
up the clock.
Hopefully everything should be OK.
So this is it.
So if you had this set to fullscreen then it would take over your entire screen.
But doing it this way you can recite it to whatever size you want and it's more it's a more flexible
approach.
OK if you want the different formats if you want to add the actual date to this.
I have also created a line of code by a comment made it out.
So let me just close this.
This line of code here I've commented it out and this one here.
So this allows you.
This will you can see the format here.
This would display both the date and the time.
So why I'm gonna jump on a comment this out if you want to comment something in Python.
You do that using the hash symbol is very useful enables you to try things out.
All right so I'm gonna use a different format here for this time.
So you're gonna give me put the date and the times I'm gonna click save and run this so you can see
the difference.
And this should hopefully show me just expand that you can see it's quite big.
Okay I probably need to reduce so you can see shows but because I've got it so big.
That's why I cover the screen or at 1 need to do.
Let me just reduce or close that call me away I've got the size of the funds are just reduce down to
60 because the screen has more to contain and I run the in-game the screen should be smaller now and
it should be able to see everything so you can see that.
So if you prefer these formats of the clock that's fine.
Then what you need to do is use this code here.
OK.
If you don't want that you don't need this.
I'll just get rid of that.
This is just I don't need that anymore.
This was just a comment.
So just Bob.
All right.
So if you decide you only want to show the time you don't want a date then you comment this line out
and use this line instead.
I prefer just a time other moments so I'm going to comment this out.
I don't want to date but it's good to have the option so that you can choose which format you like.
So I'll go back to the format I chose since I've got less text to display.
I'm going to increase the font size to 120 so that it is big on the screen.
I'll save that.
Run that again run the module and it's set up.
I prefer this format.
OK.
Make sure you save your work.
Always save it.
So when you save you go to click save as.
And I've saved mine as digital clock dot P Y P Why is the python extension Okay save anyway you like
I've saved mine on the desktop.
Okay.
So that's it.
That's the end of this project for the digital clock.
I hope it's been useful if you do have any problems.
Please feel free to contact me.
Thanks for watching.
Bye now.