Skip to content

Instantly share code, notes, and snippets.

@jjsantanna
Created March 20, 2018 10:23
Show Gist options
  • Save jjsantanna/0712548f00800f2d04be5b426705dfd8 to your computer and use it in GitHub Desktop.
Save jjsantanna/0712548f00800f2d04be5b426705dfd8 to your computer and use it in GitHub Desktop.
Countdown deadline
#!/usr/bin/python
from Tkinter import *
import ttk
import tkFont
#from Tkinter import font
import time
import datetime
global endTime
def quit(*args):
root.destroy()
def show_time():
# Get the time remaining until the event
remainder = endTime - datetime.datetime.now()
# remove the microseconds part
remainder = remainder - datetime.timedelta(microseconds=remainder.microseconds)
# Show the time left
txt.set(remainder)
# Trigger the countdown after 1000ms
root.after(1000, show_time)
# Use tkinter lib for showing the clock
root = Tk()
root.attributes("-fullscreen", True)
root.configure(background='black')
root.bind("x", quit)
root.after(1000, show_time)
# Set the end date and time for the countdown
endTime = datetime.datetime(2018, 3, 21, 0, 0, 0)
#appHighlightFont = font.Font(family='He', size=12, weight='bold')
#ttk.Label(root, text='Attention!', font=appHighlightFont).grid()
#fnt = tkFont.Font(font='DS-DIGIT', size=120, weight='bold')
txt = StringVar()
lbl = ttk.Label(root, textvariable=txt, font=("DS-Digital", 130, "bold"), foreground="yellow", background="black")
lbl.place(relx=0.5, rely=0.5, anchor=CENTER)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment