Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

cronometro python tkinter

import time
from tkinter import *
from tkinter import messagebox
 
 
root = Tk()
root.geometry("300x250")
  
root.title("Time Counter")
hour=StringVar()
minute=StringVar()
second=StringVar()
hour.set("00")
minute.set("00")
second.set("00")
hourEntry= Entry(root, width=3, font=("Arial",18,""),
                 textvariable=hour)
hourEntry.place(x=80,y=20)
  
minuteEntry= Entry(root, width=3, font=("Arial",18,""),
                   textvariable=minute)
minuteEntry.place(x=130,y=20)
  
secondEntry= Entry(root, width=3, font=("Arial",18,""),
                   textvariable=second)
secondEntry.place(x=180,y=20)
  
  
def submit():
    try:
      
        temp = int(hour.get())*3600 + int(minute.get())*60 + int(second.get())
    except:
        print("Please input the right value")
    while temp >-1:
       
        mins,secs = divmod(temp,60) 
      
        hours=0
        if mins >60:
                   hours, mins = divmod(mins, 60)
       
      hour.set("{0:2d}".format(hours))
        minute.set("{0:2d}".format(mins))
        second.set("{0:2d}".format(secs))
      root.update()
        time.sleep(1)
      if (temp == 0):
            messagebox.showinfo("Time Countdown", "Time's up ")
       
      temp -= 1
 
btn = Button(root, text='Set Time Countdown', bd='5',
             command= submit)
btn.place(x = 70,y = 120)
  
root.mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: Python Print hour, minute, second and microsecond 
Python :: python test class hashable 
Python :: complete dates pandas 
Python :: add colorbar matplotlib 
Python :: does tuple allow duplicate values in python 
Python :: required_fields = [] 
Python :: python loop with index 
Python :: instalar sympy en thonny 
Python :: how to make colab reload on form change 
Python :: python count one to ten 
Python :: python basic programs kilometers to miles 
Python :: find an element using id in requests-html library in python 
Python :: ndarray python 
Python :: find median pandas 
Python :: mosaicplot pandas 
Python :: python using strip trim white sapce 
Python :: colorbar with hist2d 
Python :: how to make a python file run in the background 
Python :: python - remove exta space in column 
Python :: Forbidden (CSRF token missing or incorrect.): /extension/stripe-pay/ WARNING 2021-06-01 13:45:22,532 log 408 140165573588736 Forbidden (CSRF token missing or incorrect.): /extension/stripe-pay/ 
Python :: convert pdf to excel python 
Python :: how to make bak files with python 
Python :: gdscript fixed decimal 
Python :: find out length of a string in pixels python 
Python :: classes in python 
Python :: create a list of sequential numbers in python 
Python :: python Cerberus 
Python :: Plot kdeplot, lineplot, scatterplot in seaborn 
Python :: python wifi moudel [WinError 2] The system cannot find the file specified 
Python :: python order list by multiple index 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =