[linux-audio-user] a live performance timer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 21 Oct 2004 00:28:29 +1000, Erik de Castro Lopo wrote
> On Wed, 20 Oct 2004 14:47:02 +0100
> "Dave Griffiths" <dave@xxxxxxxxxx> wrote:
> 
> > Hi all,
> > 
> > A timer in a window that counts up in seconds, clicking on it resets the time
> > back to 0. for seeing how much time you've got left during a live gig...
> 
> Cute! Here's a small improvement:
> 
> >
self.widget=Button(master,text="0:0",font=("Courier",50,"bold"),relief=FLAT,command=self.reset)
> 
> Replace "0:0" with " 0:00"
> 
> and this:
> 
> >         self.widget.config(text=str(thistime/60)+":"+str(thistime%60))
> 
> with
> 
>           self.widget.config(text="%2d:%02d" % (thistime / 60, 
> thistime % 60))

cheers! :) development by mailing list...

version 1.1:

--->8---

#! /usr/bin/env python
from Tkinter import *
from time import *

class clock:
	def __init__(self,master):
		self.starttime=0
		self.widget=Button(master,text="
0:00",font=("Courier",50,"bold"),relief=FLAT,command=self.reset)
		self.widget.pack()

	def idle(self):
		thistime = int(time()-self.starttime)
		self.widget.config(text="%2d:%02d" % (thistime / 60, thistime % 60))
		self.widget.after(1000, self.idle)

	def reset(self):
		if not self.starttime:
			self.widget.after_idle(self.idle)
		self.starttime=time()

win = Tk()
win.title("ticktock")
slider = clock(win)
win.mainloop()


[Index of Archives]     [Linux Sound]     [ALSA Users]     [Pulse Audio]     [ALSA Devel]     [Sox Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux