 Right, so hey guys and welcome back to another Python tutorial So this video is going to be a lot more chill than the previous tutorials we had just to kind of dump it down for New beginners that are joining my channel So in this tutorial what we're going to be doing is we're going to be programming a simple GUI digital clock that you can flex on your screens Let me show you an example of what I mean Let me run the program I already have coded up just to show you what you'd be having at the end of this tutorial Let's run this up and as you see right here. We have a little digital clock showing up on my screen So it just updates each time a second pass is by and it shows us the most Updated time so that's all we're going to be doing in this to this tutorial. We're going to go through today So first of all what I'm going to do is open up with your studio code like always and Then in there what I'm going to do is close my existing files and create a new file I'm going to zoom in a bit as well. Just so that you can see easier and then save this as Let's just call it a digital Clock Dot pie Because it's a digital clock, of course So first thing you want to do is import to kinter So we're going to be using a label from to kinter and we're going to be using the tk from to kinter so from Tkinter import tk, which is pretty much going to let us create a small window or a screen and then from to kinter Import label. We're just going to be allowing us to put some text to our screen. Cool. So first of all we want to define a master screen So if I do master equals tk and then open close brackets and run that up for you It should open up a small window But before that we also need to put it in a loop so that it keeps running So we do master dot main loop And now if I run this we should have a little pop-up window. So as you see right here, we have a little pop-up window So now let's give that window a title. So master dot title Digital clock And now what we want to do is go ahead and create a label on our screen. So clock equals Label and the master is going to be where it's going to be placed. Then we're going to set our font size to We're going to set it to calibrary type and then we're going to set the font size to 90 so that it pretty much covers up the screen nicely I'm going to set my background to gray You guys can go ahead and put your color preferences in there and I'm going to set my foreground, which is the color of my text to white Cool. So now what I'm going to do is go ahead and pack this clock onto my screen So what pack does is it pretty much puts this label at the center of my screen? Now as of now if I run this obviously nothing's going to show up. It's just going to be a little Kind of label which is in the center of the screen. We've got to put text on there So for this we need to have a function that pretty much calls itself again and again every time the time updates or every few seconds So that's what we're going to be doing. So let's create a function called def get time Now this function right here is going to be getting the time for us and then updating the label Every 20 every 0.2 or for a millisecond. So before that what we want to do is import time And let's also do import system So these are the two modules that are going to help us gather the time and store it as a string So time variable equals time dot string F time So in here what we can do is format the time that we're having as a As pretty much how we want it to display. So I want to display Percentage i which means hours then I want to percentage m which is minutes then I'm going to use percentage s which is seconds and then lastly percentage p which will show either a m or p m Cool. So that's that done. We've got the string showing up now. Now what we want to do is use clock Clock which is the name of the label that we created dot config so that we can add some text to it So text equals Time variable So that's the variable that was storing the time for us Now what we want to do here is go ahead and use the clock dot after method, which means every Point two of a second. We are going to run this function again So every every zero point every second of a second So like every 200 milliseconds, we're going to run this function again so that we get the most recent time and it's being put on our label Cool. So once we're done with that, we also need to call this get time function once after the Label has been packed on our screen. So get time and run it now. And that's about it. Now if I run this quickly As you see right here, we are able to see our little digital clock on the top of our screen So that's a nice little startup project for you guys to flex on your friends or something like that It's it's pretty good. It looks like a neat UI You guys can also change the design if you like. So for example, if I wanted to change the background to black And foreground still to white and if I run it now It changes whatever I want. So background is black and then the foreground is white Um, what if I wanted to change the font size? I can go ahead and do that over here So I can do 100 instead of 90 And then it goes slightly bigger Um, also if I wanted to change it to a different font family I could do it so by typing in aerial in here for example instead of calibrary and it should adjust automatically So as you see it's aerial now Um, also if you wanted to What else can you do with this? You could also add some extra text to it like an extra label. So you could do something like um Label master comma font equals aerial Let's go with font size of I don't know. Let's say 30 and then let's do comma text equals uh digital block foreground equals white And background equals black just to keep being consistent And then we just use a dot pack so that we pack it onto a screen in the center Cool. So as you see right here, we could also do that if you like Obviously, it's up to your personal preferences how you want this to be designed But hey, that's what you can do if you like as well So that brings an end to this short tutorial guys. Hope you have learned a little bit during this short tutorial. Um Hope you would be able to use this to create a sort of your own project You can also create an alarm out of it if you like by adding a few um functions and buttons onto the c y And that's it if you guys would like to donate to the channel directly You can do so by either signing up as a patron and using the patreon link in the description You can also um use a super chat emoji or a highlighted message when this video premieres Also guys do consider joining the discord channel and following the socials for some more fun And I will see you beautiful faces in the next tutorial. Peace