Skip to content

Commit

Permalink
leaving awi
Browse files Browse the repository at this point in the history
  • Loading branch information
pf4d committed Jan 15, 2019
1 parent 758ae65 commit 960afcc
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions tk_stopwatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ def update_timeText():
global timer
# Every time this function is called,
# we will increment 1 centisecond (1/100 of a second)
timer[3] += 1
timer[2] += 1

# Every 100 centisecond is equal to 1 second
if (timer[3] >= 100):
timer[3] = 0
timer[2] += 1
# Every 60 seconds is equal to 1 min
if (timer[2] >= 60):
timer[1] += 1
Expand All @@ -30,8 +26,8 @@ def update_timeText():
timeString = pattern.format(*timer)
# Update the timeText Label box with the current time
timeText.configure(text=timeString)
# Call the update_timeText() function after 1 centisecond
root.after(10, update_timeText)
# Call the update_timeText() function after 1 centisecond
root.after(1000, update_timeText)

# To start the kitchen timer
def start():
Expand All @@ -46,8 +42,8 @@ def pause():
# To reset the timer to 00:00:00
def reset():
global timer
timer = [0, 0, 0, 0]
timeText.configure(text='00:00:00:00')
timer = [0, 0, 0]
timeText.configure(text='00:00:00')

# To exist our program
def exist():
Expand All @@ -62,12 +58,12 @@ def exist():
root.wm_title('timer')

# Our time structure [hour, min, sec, centsec]
timer = [0, 0, 0, 0]
timer = [0, 0, 0]
# The format is padding all the
pattern = '{0:02d}:{1:02d}:{2:02d}:{3:02d}'
pattern = '{0:02d}:{1:02d}:{2:02d}'

# Create a timeText Label (a text box)
timeText = tk.Label(root, text="00:00:00:00", font=("mono", 20))
timeText = tk.Label(root, text="00:00:00", font=("mono", 20))
timeText.pack()

startButton = tk.Button(root, text='start', font=("mono", 8), command=start)
Expand Down

0 comments on commit 960afcc

Please sign in to comment.