Let's code a CLOCK PROGRAM in python! 🕒
HTML-код
- Опубликовано: 15 сен 2020
- Python clock program app tutorial for beginners
#Python #clock #program #app #code #GUI #tkinter #tutorial
from tkinter import *
from time import *
def update():
time_string = strftime("%I:%M:%S %p")
time_label.config(text=time_string)
day_string = strftime("%A")
day_label.config(text=day_string)
date_string = strftime("%B %d, %Y")
date_label.config(text=date_string)
window.after(1000,update)
window = Tk()
time_label = Label(window,font=("Arial",50),fg="#00FF00",bg="black")
time_label.pack()
day_label = Label(window,font=("Ink Free",25,"bold"))
day_label.pack()
date_label = Label(window,font=("Ink Free",30))
date_label.pack()
update()
window.mainloop() Наука
from tkinter import *
from time import *
def update():
time_string = strftime("%I:%M:%S %p")
time_label.config(text=time_string)
day_string = strftime("%A")
day_label.config(text=day_string)
date_string = strftime("%B %d, %Y")
date_label.config(text=date_string)
window.after(1000,update)
window = Tk()
time_label = Label(window,font=("Arial",50),fg="#00FF00",bg="black")
time_label.pack()
day_label = Label(window,font=("Ink Free",25,"bold"))
day_label.pack()
date_label = Label(window,font=("Ink Free",30))
date_label.pack()
update()
window.mainloop()
It says that it's not defined
@@alexdemeter1558 dont copy that
Thank you very much my friend for sharing your precious knowledge with us. You really know how to get us into coding...
There is no more world to thank you...
You Sir is one of a life saver, Currently I'm developing a solo project of AlertAnnouncement/Schedule for schools and I'm struggling for a RTC concept code and this just saved my butt for weeks. Thanks for exsisting!
Nice work!
excellent tutorial man!
very thanks, it is useful 👍
Hay you I’m taking to you. Really I like your video. I commented , liked and subscribed. Thank you.
Great tutorial!
This is an especially cool one, it makes you feel as if you've done something!
hiii! i really enjoyed this video, thank you for explaining everything so well :)
Great vid!
Superb Bro
thank you so much for uploading this video
Fantastic
Fantastic 🎉🎉🎉🎉
Excellent 🎉
Bro you r great...
Excellent 👌
Nice.
And thanks for sparing time for us....
good part
Thank you so very much😀😃😄
Thank you Bro!
thank you for dis bro
Thanks
Thanks man
Thanks!
thanks for watching David
Hey Dude, you really do make videos at 6:46 in the morning? :)
And thank you for your great content!
most probable he was working all night and finished that day at that time, it happens when you are passionate about your job
thx
how can u do multiple languages at once.....u realy inspired me
Good
gr8
i want to learn how to do python coding made simple
good
bro how does it toke from you to learn all this (Java , C++ , C , JavaScript , Python )
F@ck! It seems it's what I looking for! Thank you!
Re-watching this while making a To do list app project
how can i change the time to 7:77:77 pls i m not crazy or smth i need it xd and ty
I have an error in line 14, help me!
whats the difference between from time import * and import time?
from time import * imports everything from the time namespace directly into the current namespace.
e.g.
import time
time.sleep(1)
vs
from time import *
sleep(1)
Generally it's bad practice to import * as you have no idea what you're importing and it could end up in name clashes.
It's best to do
from time import sleep
or
import time
and if you end up with a name clash you can do
from time import sleep as standard_sleep
standard_sleep(1)
This applies to any Python package.
tysm@@Wock__
a comment like u told 😅
from tkinter import *
from time import *
def update():
time_string = strftime("%I%M%S"")
time_label.cfig(text=time_string)
window = Tk()
time_label = Label(window,font=("Arial",50),fg="#00FF00",bg="black")
time_labe.pack()
update()
window.mainllop()
I tried this code but seconds is not updating
Won't all that recursion cause a call stack overflow?
From a stackoverflow answer to this: after works differently, and is not recursion.
The call to after writes to a todo list that the main program needs to call update(). Then this run of update completes and the flow goes back to the main program. then a second later the main program calls update again.
I rather prefer to call symbol '%' as mode or modulo, rather than 'percentage'.
who watched this on a wednesday? edit: not only is it a wednesday... it is september 1st... almost one year anniversary, crazy...
It isn't working.
from tkinter import *
from time import strftime
root = Tk()
root.title("Menu")
def open():
top = Toplevel()
top.title("Date")
my_label = Label(top,text = strftime("%I:%M:%S %p"), font="ds-digital",bg="black",fg="cyan" )
my_label.after(1000,open)
my_label.pack()
btn = Button(root, text="clock", command=open)
btn.pack()
mainloop()
can anyone solve this why evert time new window of clock opens
cause you execute the open function every 1000ms, which generates a new label
comment
step 3 = done
step 1 = done 👍
step 2 = done 🗯
thx very much Bro, really helps! Keep on going!
excellent tutorial man!