Hello and welcome to this video.
This is gonna be a three part video series where we are going to create a count down timer using Python.
Calm down time has a very useful.
You can use that to count down to several events for example.
Holidays and other related events that are of interest to you to begin our development.
You need to open up the python shell and you can access it.
Fi your programs menu inside the python folder there is the idol just double click on the idle and that
will open up this shell.
So once you've got the shell open we need to open up a new window.
So you go file a new file and inside this area here we will develop our application.
So the first thing you need to do is save the file so you do file save as and you can save it anywhere
you like but just save it with a dot P Y extension actually you don't need to because it's already done
that for you here or you need to just give it a name.
So I'm going to call my count down and I'll just save it and I'll save it on my desktop.
OK.
So I've got the file so this now is a python file.
I want to use some Python libraries.
So before I use them I need to import them.
I'm going to import t counter which is a module that is used to create user interfaces of various types.
So to import that I just need to type typing from space teak into
King ter can't spell today Kintore.
That's it from TI Kintore.
They type in the word import
space Asterix.
So with the asterisks it will import the library mix who want to import whole nother library.
It's also a subset of T Kintore to do to take into space import space.
This one's called t t k.
Next we won't import a t type font.
So we can use a font from t kin to you type in the word import followed by or too important to import
in the font element.
Next I want to import the time module so I'm just typing.
Import time I also want to import the date time so I type import
date time.
All right.
So I've got all my libraries and class methods ready.
First thing I want to do is create a variable.
It's gonna be a global variable a global variable means it will be available throughout the application
Python variables are scope base where you can have a variable that is local or exist only within the
module but by declaring it global that means I want the available throughout the application so I just
type in the word global followed by the name I want to call it.
I'm going to call it and times who will use that later in the application.
So I want to create our first function here and to create a function you type in D F followed by the
name.
I'm going to call this can't underscore wait I'm going to be the name of my function actually before
I create that function I want to create another one of us not create a function called quit.
This will allow us to quit the application and inside the parentheses I'm going to pass it arguments.
Okay.
And that's it and semicolon you use the asterisks and the KRG is which stands for argument.
So what you normally do when you're not sure how many arguments might be passed to your function you
used the asterisks and eggs.
What that does it allows you to pass an arbitrary number of arguments to your function and inside this
quit function.
I'm going to had a root metros and was a root dot this Troy
what the root dot destroyed does it will cause the main loop of the application to exit.
So when the application kept running and this font with this function of this method is called it will
exit the application from the look.
One more thing I want to do before we wrap up this video lecture I want to create on another function
this time I'll call it
can't on the score wait but feel free to call use whatever you like.
And then the parentheses and the call on and I'm going to create a variable and I'm going to call this
variable time left and and went to set that to a course to the end time variable which is this variable
here.
The global one so I'm certain it two equals two that minus the date time dot the time date time the
day time dot.
Now that this is method a time function we've imported the day time and the time module has we're able
to utilize it here.
This will give us the current time.
So if we take away B value of this and time from this method here it will give us the time left over
for our event.
I have added some more line of code so as to save time so a mother this line here.
What this does it takes away the micro seconds.
Okay.
So if without doubt the time would display after the cyclone Yasi tore through so sure some microseconds.
So I'm using this value here to take away the microsecond so that we don't have that displayed and then
here I have created.
This is what will display the clock.
Ok this will show the time that is left to your particular event.
This is what we've used to set that time.
And this here this piece of code here is used to trigger the countdown after one thousand milli seconds.
So I'm going to end this lecture here and we'll continue in part to where we'll start to build the interface
for the countdown clock.
So make sure you save your work.
Just keep files save and we'll see you in part two.
Thanks for watching.
Bye for now.