Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
LeWolfYT authored Apr 15, 2022
0 parents commit 03abdbd
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
54 changes: 54 additions & 0 deletions clock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#make a digital clock that has big numbers to show the time for easy reading
#import the modules needed (the only tkinter modules we need are tkinter and tkinter.ttk)
#we also need the time module to get the current time


import tkinter as tk
import time


#create the main window (the title is "Simple Clock" and the window is 500x160)
clockrt = tk.Tk()
clockrt.title("Simple Clock")
clockrt.geometry("500x160")
clockrt.wm_attributes("-topmost", 1)

#the time will be displayed in a label that fills almost the entire window
#the label is created with the text "00:00" and the font size is the value of the variable "font_size"
#the label is placed in the center of the window
#the label is given a background color of white
#the label is given a foreground color of black
#the label is given a borderwidth of 0
#the label is given a relief of flat
#the colon blinks on or off every second (depends on whether it was on or off last second)
#the colon is just part of the label's text and is not a separate label

#create label
font_size = 110
label = tk.Label(clockrt, text="00:00", font=("Helvetica", font_size), bg="white", fg="black", borderwidth=0, relief="flat")
label.place(relx=0.5, rely=0.5, anchor="center")


#create the function that draws the label with the time (it has a forever loop that changes the time every second)
def draw_label():
#if the current second is even, turn the colon on. else, turn it off
if time.localtime().tm_sec % 2 == 0:
colon = ":"
else:
colon = " "
#get the current time
current_time = time.strftime("%I"+colon+"%M %p")
#set the label's text to the time
label.config(text=current_time)
#wait one second
clockrt.after(1000, draw_label)


#start the main loop
def mainstuff():
#call the function that draws the label
draw_label()
#start the main loop
clockrt.mainloop()

mainstuff()
19 changes: 19 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""

from setuptools import setup

APP = ['clock.py']
DATA_FILES = []
OPTIONS = {}

setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)

0 comments on commit 03abdbd

Please sign in to comment.