Programming language, Python Gui Clock With Python and Tkinker #python #gui
So today we are going to create a simple gui clock using python. Now those of you who dont know what gui is gui is basically a graphical user interference. Now, a graphical user interference is something which has some graphics so like apps, like vs code or chrome, all have some graphics. They do run some certain codes behind the graphics which run in the console or what you call as cmd, but they also show something to us. Now we need to install this pack, not package text package ill, give the link in the description. Now you will install that and then we will start coding now. What i need you to do is import the modules. Now these are the modules we will need. We will need tinker, we will need tinker.ttk and time, so we will create a window named root and we will provide it. A labeled name, such as clock or digital flock. Anything you want um. You can also change the name like this, like digital clock, and you can provide any name like adityas clock or anything else, but ill keep the name clock thats appropriate. Now we will create a function which will tell us the current time every second now i have written their thousands so that it changes the updates the time every one. Second thousand milliseconds is one second. Now i will give the colors background and foreground now background means. The color which is at back and foreground, is the color of the text.
Now you can choose any color using the hex code. You will go to google and search for color picker. Now this interference will appear in front of you. You can choose any color, like suppose, i want to choose blue color, so ill, go to this neon blue and just pick any color, which i want and then copy the hex code and ill paste it. Where the background or foreground, whichever color you like, is written now, you already know what background and foreground means. Now i am using digital 7. As my text, you can use any other font and if you use then no need to install the font packages which ill give now we will. We have created everything. Now we have to call the so here we will call the functions. Whatever functions are required, so we have created two functions, that is time and the main loop which is created by take inter so we will call these functions using the respective commands like time and main loop. So we have to import that and then we can save this file and run it now. You see this is our gui now. What is the problem with this gui? Is that whenever i run this, we also see a command prompt, which is blank and its of no use right. So what i want you to do is type the command pip install auto pi to exe. So this is a python program which basically gives you a gui for creating the python packages.
So you will install this. I have already installed this, so i can see requirement already satisfied so ill close this and open a cmd again so ill now ill type, auto dash, pi dash 2 and dash exe. Now this will open a gui in front of you in the local host in chrome window or whatever is your default browser so yeah? You will see this thing and, first of all, you need to select which thing or which folder or which python program you want to convert into exe. So we have this file named main dot py. So we have to locate these using the browser command. We will just go ahead and click on browser, so here you can select, which is the one file or one directory command ill, recommend that you use one file so that the things get easier for the person who downloads your app. So we will just browse our file yeah, i got it main dot, py and then well. Select one file – and this is the thing you want to know – console or window based now console base – is what we called as cmd and windows based its something which will hide the console, hide the cmd. Now you can select some icons for your file. You can add some additional files and we will do that so well. Add the files which are the requirements or what you can say is these are the fonts which the person who is downloading our file will require.
So now you can change the name and things so we will just convert this to python now. I have fast forwarded this part of the video, because this is a quite lengthy process. It might take you two to three minutes, so you will wait and yeah its all done and you will see one folder named output is created. You can click the show output button so that you can see the output folder if its not in your root directory. So now we will open this output folder. Now you see this is our main dot exe. Now you might see a python icon there, but it does not matter. It is anyways in form of application. That is exe. Now we will run this. So this might take a few seconds at the first time to run because it has to hide the console and it has to gain some permissions. It also has to install the fonts. You will wait a second and then you will see your clock is ready. Now this is our clock, so it works. Absolutely fine and you see there is no command prompt. Now you can see there is no command prompt, so this is our fully made app or you can say exe now.