Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import time
- import os
- quitting = False
- alarm_state = False
- def quitter(): # function controls how the application should close
- global quitting
- quitting = True
- win = Tk()
- win.title("Clock")
- win.protocol("WM_DELETE_WINDOW", quitter) ## runs the function when the X button is pressed.
- example = Label(win,font=('times', 28, 'bold'), background='blue', foreground='white')
- example.pack(fill=BOTH, expand=1)
- e1=Entry(win)
- e1.pack()
- def button():
- global alarm_state
- alarm_state = True
- bt=Button(win, text='Set alarm', command=button).pack()
- def check_alarm(settime):
- global alarm_state
- if settime.get()==time.strftime('%H:%M:%S') and alarm_state:
- print("Times Up!")
- alarm_state = False
- while not quitting:
- win.update()
- win.update_idletasks()
- example["text"] = time.strftime('%H:%M:%S')
- check_alarm(e1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement