Hello and welcome to this video.
This is going to be a two part video where we are going to create a digital clock using python from
scratch.
The first thing you need to do is open up the python shell and you can access the show by the python
folder.
So if you go to your Programs menu and inside the python folder just click on this.
That is a point on Idol and will open up the shell.
Once you've got the shell open we need to open up a new file.
So you click file and click new file.
So this new file here is where we'll actually write a program and any errors that occur will be displayed
in the shell.
We are going to use a few Python libraries.
So we need to import them before we use them.
The first the library you're going to import is the T counter library.
So we need to import that by typing in from in lowercase space.
And then the word T into space import and then Asterix and this will import the take into library.
So it's available for us to use.
So it's the first line you have to put in if you are going to use the T counter in your program.
Take him to his library that is used to build user interfaces or interfaces in general.
So we're going to import a sub library also from teak into.
So we save from teak into this one is going to be called T T K next going to import the font.
We want to use a font to take him also has fonts you can use.
So to take into import
font
next we are going to import the time module cause we need to use that import time.
Next I'm going to do is import a module for date time when we can make reference to that.
So that's it.
We've called all libraries next want to create a function.
So the f is what you used to define a function.
And I'm going to call this function quit so we'll use this to quit the application and I've been passing
the arguments a R G S and the column makes you typing root dot this Troy
inside the function we've just defined we've got an asterix followed by the word a R G is basically
what that is used for is used inside function definitions and it's used to pass a non key word variable
length so it will allow you to pass key non key word at variable length arguments as a list kind of
like an array which allows you to pass several arguments provided they are not key words key words sometimes
are reserved for the program so you can actually use.
Next we've got the route dot destroy method what this will do it will.
Course the main loop to exit.
So when you are at the end of the way you close the window for the application does the method that
would trigger the application to close it we just closed the session the next thing going to do is create
an another function.
This will be for our clock.
So we're going to say D F I'm going to call it a clock on the score time you can call it whatever you
want it doesn't really matter so I'm just calling it clock.
All right.
And you put a call on after that.
Next thing I want to do is define a variable.
I want to call a variable time and I'm going to set this variable to equal to the date time.
Don't forget we import it did take time.
So we can use it now.
So to date time dot date time dot now which would give us to the current time the date or time method
returns that current time.
Also Emily milliseconds so I want to avoid that so to do that I'll need to format the time using a special
format function.
So to do that I've got to reference the time variable again and I'm going to have to set that to a course
to an hour rapid round the variable dot.
This is a special function here as call s t r f time.
This is used to is a function used to format the time based on the arguments of past time.
So I'm going to enclose that in double quotes and I'll pass in the format I want.
So I want our call on and I want the minute I put cologne on I want these seconds and I close the double
quotes close the parentheses and close the other parentheses.
Next thing I want to do is find a way to display our time.
So when I do text say T T which is text we can to set that to a course to the time variable so there
is a functional metal code set don't touch this text.
Dots time we text set.
So this is a method and we're passing in this time variable here as the value.
Next we want to trigger the clock so that eight stars of every one milliseconds.
So we do route dot after and inside parentheses.
We're passing the milliseconds a comma and then we're passing the function which is a clock block on
the score time
plus it.
So we'll end this video here and in part two we will continue.
So thanks for watching.
And by phone.