Stopwatch - pause counter

Terry Reedy tjreedy at
Tue Jul 19 20:55:49 CEST 2011

On 7/19/2011 6:41 AM, Morten Klim wrote:
> Hello everyone!
> I've started developing a little application for one of my friends,
> which he will use at work to measure his hours working + the time he
> has breaks. I wanna do this in python cause, I just started with this
> language and wanna get more fimiliar with it. Sometimes though, it's a
> bit of a struggle.
> I found a nice stopwatch using tkinter, and I've modified it a bit to
> my needs. The only thing I'm missing now is he wan't a pause counter,
> for how long the pause button has been pushed.
> An example:
> I've worked for 2 hours, and wanna go for a break, I push the pause
> button.
> The pause counter then starts ticking, until the start button is
> pressed again. So I have both a counter for working hours and pause
> hours. If the pause button is pressed again,

when working or when already paused?

 > the current time he has kept his break can't be reset,
 >  so it has to add the new time it to the current.
> I hope that made sense.

Not really. This is basically a finite-statement machine, but I am not 
sure what state-input transition matrix you intend.

> Here is my code:

Python3 code. Pastebin has a bug that is adds spaces (where line number 
were) that were not pasted in when one copies the text out. So one must 
dedent the entire file after pasting into an editor window (IDLE does 
this pretty easily with two dedents).

The code looks pretty good and it initially ran, but when I clicked 
Start (starts counting seconds), Pause (starts counting pause seconds), 
Start (continued with cumulative time), and then Pause, counters goes 
crazy, flashing various second readings several times a second. There 
may be an tkinter bug, but if you can resume work time, you should be 
able to resume pause time. Again, without a design spec, it is hard to 
know what you intended.

Start, Pause, Reset (no obvious effect), Start has same effect.

> The variables at __init__
> self._pausestart = 0.0
> self._elapsedpause = 0.0
> and the method _updatepause are a attempt to make this work.

Terry Jan Reedy

More information about the Python-list mailing list