First step to adding test timing support: create gtk Clock widget (clock.py).

portnov [2008-05-31 16:27:49]
First step to adding test timing support: create gtk Clock widget (clock.py).
Filename
.REPORTGEN-README.swp
.reportgen.py.swp
.sqlite_backend.py.swp
.test_client.py.swp
clock.py
mpout.log
out
diff --git a/.REPORTGEN-README.swp b/.REPORTGEN-README.swp
deleted file mode 100644
index 3be8baa..0000000
Binary files a/.REPORTGEN-README.swp and /dev/null differ
diff --git a/.reportgen.py.swp b/.reportgen.py.swp
deleted file mode 100644
index 36ceaac..0000000
Binary files a/.reportgen.py.swp and /dev/null differ
diff --git a/.sqlite_backend.py.swp b/.sqlite_backend.py.swp
deleted file mode 100644
index f681d31..0000000
Binary files a/.sqlite_backend.py.swp and /dev/null differ
diff --git a/.test_client.py.swp b/.test_client.py.swp
deleted file mode 100644
index db6e3f9..0000000
Binary files a/.test_client.py.swp and /dev/null differ
diff --git a/clock.py b/clock.py
new file mode 100755
index 0000000..9d53f13
--- /dev/null
+++ b/clock.py
@@ -0,0 +1,111 @@
+#!/usr/bin/python
+
+import gtk
+import gobject
+
+class Time(object):
+  def __init__(self,time=None):
+    if time:
+      if (type(time) == str) or (type(time) == unicode):
+        h,m,s = map(int,time.split(':'))
+        self._seconds = h*3600 + m*60 + s
+      elif type(time) == int:
+        self._seconds = time
+    else:
+      self._seconds = 0
+
+  def _gethms(self):
+    h = self._seconds // 3600
+    m = (self._seconds % 3600) // 60
+    s = self._seconds % 60
+    return h,m,s
+
+  def _sethms(self,hms):
+    h,m,s = hms
+    self._seconds = h*3600 + m*60 + s
+
+  hms = property(_gethms,_sethms)
+
+  def _gethours(self):
+    return self._seconds//3600
+
+  def _sethours(self,value):
+    self._seconds = (self._seconds % 3600) + value*3600
+
+  hours = property(_gethours,_sethours)
+
+  def _getminutes(self):
+    return (self._seconds % 3600) // 60
+
+  def _setminutes(self,value):
+    h,m,s = self.hms
+    self.hms = h, value, s
+
+  minutes = property(_getminutes,_setminutes)
+
+  def _getseconds(self):
+    return self._seconds % 60
+
+  def _setseconds(self,value):
+    self._seconds = (self._seconds //60) * 60 + value
+
+  seconds = property(_getseconds,_setseconds)
+
+  def __add__(self,value):
+    if type(value) != int:
+      raise ValueError, "Only integer value may be added to Time value!"
+    return Time(self._seconds + value)
+
+  def __sub__(self,value):
+    if type(value) != int:
+      raise ValueError, "Only integer value may be substracted from Time value!"
+    return Time(self._seconds - value)
+
+  def __str__(self):
+    return "%02d:%02d:%02d" % (self.hours,self.minutes,self.seconds)
+
+  def __repr__(self):
+    return "<Time object: %02d:%02d:%02d>" % (self.hours,self.minutes,self.seconds)
+
+class Clock(gtk.Label):
+  def __init__(self,time=None):
+    gtk.Label.__init__(self)
+    self.set_time(time)
+    self.on_end = None
+
+  def set_time(self,time=None):
+    if time:
+      if type(time) == str:
+        self.time = Time(time)
+      elif type(time) == Time:
+        self.time = time
+    else:
+      self.time = Time()
+    self.set_label(str(self.time))
+
+  def __on_timer(self):
+    self.time += self.counter
+    self.set_label(str(self.time))
+    if self.time == Time():
+      if self.on_end:
+        self.on_end()
+      return False
+    return True
+
+  def start(self):
+    self.counter = 1
+    gobject.timeout_add(1000,self.__on_timer)
+
+  def count_down(self):
+    self.counter = -1
+    gobject.timeout_add(1000,self.__on_timer)
+
+if __name__ == "__main__":
+  wnd = gtk.Window()
+  wnd.connect("delete_event",gtk.main_quit)
+  clock = Clock("1:00:00")
+  wnd.add(clock)
+  wnd.show_all()
+  clock.count_down()
+
+  gtk.main()
diff --git a/mpout.log b/mpout.log
deleted file mode 100644
index 2e56add..0000000
--- a/mpout.log
+++ /dev/null
@@ -1,18 +0,0 @@
-This is MetaPost, Version 0.993 (Web2C 7.5.6) (mem=mpost 2008.2.25)  25 FEB 2008 21:36
-**\relax
-
-*label("aaa",(0,0));
-
-*string l;
-
-*l:="zzz";
-
-*label(l,(0,0));
-
-*
-! Emergency stop.
-<*> label(l,(0,0));
-
-End of file on the terminal!
-
-
diff --git a/out b/out
deleted file mode 100644
index 7d88e83..0000000
--- a/out
+++ /dev/null
@@ -1,354 +0,0 @@
-%!PS-Adobe-3.0 EPSF-3.0
-%%Title: ploticus-graphic
-%%Creator: ploticus (http://ploticus.sourceforge.net)
-%%BoundingBox: 37 92 271 220
-
-%%EndComments
-
-
-%%BeginProlog
-userdict begin
-/sset
-{ translate rotate } def
-/sclr
-{ rotate translate } def
-/mv { moveto } def
-/np { newpath } def
-/ln { lineto } def
-/st { stroke } def
-/sh { show } def
-/cent { stringwidth pop sub 2 div 0 rmoveto } def
-/rjust { stringwidth pop sub 0 rmoveto } def
-/reencodeISO {
-dup dup findfont dup length dict begin
-{ 1 index /FID ne { def }{ pop pop } ifelse } forall
-currentdict /CharStrings known {
-        CharStrings /Idieresis known {
-                /Encoding ISOLatin1Encoding def } if
-} if
-currentdict end definefont
-} def
-/ISOLatin1Encoding [
-/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
-/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
-/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
-/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
-/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright
-/parenleft/parenright/asterisk/plus/comma/minus/period/slash
-/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon
-/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N
-/O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright
-/asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m
-/n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde
-/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
-/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
-/.notdef/dotlessi/grave/acute/circumflex/tilde/macron/breve
-/dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut
-/ogonek/caron/space/exclamdown/cent/sterling/currency/yen/brokenbar
-/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot
-/hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior
-/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine
-/guillemotright/onequarter/onehalf/threequarters/questiondown
-/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla
-/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
-/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
-/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute
-/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis
-/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave
-/iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex
-/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis
-/yacute/thorn/ydieresis
-] def
-/Helvetica reencodeISO
-10 scalefont setfont
-%%EndProlog
-/Helvetica reencodeISO
-10 scalefont
-setfont
-0.6 setlinewidth
-[] 0 setdash
-np
-158.00 152.00 mv
-158.00 195.20 ln
-159.30 195.18 ln
-160.59 195.12 ln
-161.88 195.03 ln
-163.17 194.89 ln
-164.46 194.71 ln
-165.73 194.50 ln
-167.01 194.25 ln
-168.27 193.96 ln
-169.52 193.63 ln
-170.77 193.27 ln
-172.00 192.87 ln
-173.22 192.43 ln
-174.42 191.96 ln
-175.62 191.45 ln
-176.79 190.90 ln
-177.95 190.32 ln
-179.09 189.70 ln
-180.21 189.05 ln
-181.31 188.37 ln
-182.39 187.65 ln
-183.45 186.91 ln
-184.49 186.13 ln
-185.50 185.32 ln
-186.49 184.48 ln
-187.45 183.61 ln
-188.38 182.71 ln
-189.29 181.79 ln
-190.17 180.83 ln
-191.02 179.86 ln
-191.84 178.85 ln
-192.63 177.83 ln
-193.39 176.78 ln
-194.12 175.70 ln
-194.81 174.61 ln
-195.47 173.49 ln
-196.10 172.36 ln
-196.69 171.21 ln
-197.25 170.04 ln
-197.78 168.85 ln
-198.26 167.65 ln
-198.72 166.44 ln
-199.13 165.21 ln
-199.51 163.97 ln
-199.85 162.72 ln
-200.15 161.46 ln
-200.42 160.19 ln
-200.64 158.92 ln
-200.83 157.63 ln
-200.98 156.35 ln
-201.10 154.95 ln
-158.00 152.00 ln
-1 0 0 setrgbcolor
-closepath
-fill
-np
-158.00 152.00 mv
-201.10 154.95 ln
-201.17 153.65 ln
-201.20 152.36 ln
-201.19 151.06 ln
-201.14 149.77 ln
-201.06 148.47 ln
-200.93 147.18 ln
-200.77 145.90 ln
-200.56 144.62 ln
-200.32 143.35 ln
-200.05 142.08 ln
-199.73 140.82 ln
-199.37 139.58 ln
-198.98 138.34 ln
-198.56 137.12 ln
-198.09 135.91 ln
-197.59 134.71 ln
-197.05 133.53 ln
-196.48 132.37 ln
-195.88 131.22 ln
-195.24 130.10 ln
-194.56 128.99 ln
-193.86 127.90 ln
-193.12 126.84 ln
-192.35 125.80 ln
-191.54 124.78 ln
-190.71 123.78 ln
-189.85 122.82 ln
-188.96 121.87 ln
-188.04 120.96 ln
-187.10 120.07 ln
-186.13 119.21 ln
-185.13 118.38 ln
-184.11 117.59 ln
-183.07 116.82 ln
-182.00 116.08 ln
-180.91 115.38 ln
-179.81 114.71 ln
-177.87 113.64 ln
-158.00 152.00 ln
-0 0 1 setrgbcolor
-closepath
-fill
-np
-158.00 152.00 mv
-177.87 113.64 ln
-176.72 113.06 ln
-175.54 112.52 ln
-174.35 112.01 ln
-173.14 111.54 ln
-171.92 111.10 ln
-170.69 110.70 ln
-169.44 110.34 ln
-168.19 110.02 ln
-166.92 109.73 ln
-165.65 109.48 ln
-164.37 109.27 ln
-163.09 109.10 ln
-161.80 108.97 ln
-160.51 108.87 ln
-159.21 108.82 ln
-157.92 108.80 ln
-156.62 108.82 ln
-155.33 108.88 ln
-154.03 108.98 ln
-152.75 109.12 ln
-151.46 109.30 ln
-150.18 109.51 ln
-148.91 109.77 ln
-147.65 110.06 ln
-146.40 110.39 ln
-145.15 110.75 ln
-143.92 111.16 ln
-142.70 111.60 ln
-141.50 112.08 ln
-140.31 112.59 ln
-139.13 113.14 ln
-137.98 113.72 ln
-136.84 114.34 ln
-135.72 114.99 ln
-134.62 115.68 ln
-133.54 116.39 ln
-132.48 117.14 ln
-131.45 117.92 ln
-130.44 118.74 ln
-129.45 119.58 ln
-128.49 120.45 ln
-127.56 121.35 ln
-126.65 122.27 ln
-125.78 123.23 ln
-124.93 124.21 ln
-124.11 125.21 ln
-123.32 126.24 ln
-122.56 127.29 ln
-121.84 128.37 ln
-121.09 129.55 ln
-158.00 152.00 ln
-0 0.7 0 setrgbcolor
-closepath
-fill
-np
-158.00 152.00 mv
-121.09 129.55 ln
-120.43 130.67 ln
-119.81 131.81 ln
-119.22 132.96 ln
-118.67 134.13 ln
-118.15 135.32 ln
-117.67 136.53 ln
-117.22 137.74 ln
-116.81 138.97 ln
-116.44 140.21 ln
-116.10 141.46 ln
-115.81 142.73 ln
-115.55 144.00 ln
-115.33 145.27 ln
-115.14 146.56 ln
-115.00 147.84 ln
-114.90 149.14 ln
-114.83 150.43 ln
-114.80 151.73 ln
-114.81 153.02 ln
-114.86 154.32 ln
-114.95 155.61 ln
-115.08 156.90 ln
-115.24 158.18 ln
-115.45 159.46 ln
-115.69 160.74 ln
-115.97 162.00 ln
-116.29 163.26 ln
-116.65 164.50 ln
-117.04 165.74 ln
-117.47 166.96 ln
-117.94 168.17 ln
-118.44 169.36 ln
-118.98 170.54 ln
-119.56 171.70 ln
-120.16 172.85 ln
-120.81 173.97 ln
-121.48 175.08 ln
-122.19 176.17 ln
-122.93 177.23 ln
-123.70 178.27 ln
-124.51 179.29 ln
-125.34 180.28 ln
-126.43 181.49 ln
-158.00 152.00 ln
-0.92 0.92 0 setrgbcolor
-closepath
-fill
-np
-158.00 152.00 mv
-126.43 181.49 ln
-127.33 182.42 ln
-128.25 183.33 ln
-129.21 184.20 ln
-130.19 185.05 ln
-131.19 185.87 ln
-132.22 186.66 ln
-133.27 187.42 ln
-134.34 188.15 ln
-135.44 188.84 ln
-136.55 189.50 ln
-137.69 190.13 ln
-138.84 190.72 ln
-140.01 191.28 ln
-141.20 191.80 ln
-142.40 192.28 ln
-143.61 192.73 ln
-144.84 193.15 ln
-146.08 193.52 ln
-147.33 193.86 ln
-148.59 194.16 ln
-149.86 194.43 ln
-151.14 194.65 ln
-152.42 194.84 ln
-153.71 194.99 ln
-155.00 195.10 ln
-156.29 195.17 ln
-158.00 195.20 ln
-158.00 152.00 ln
-0.67 0.3 0.67 setrgbcolor
-closepath
-fill
-0.5 setlinewidth
-[] 0 setdash
-0 0 0 setrgbcolor
-np
-184.54 180.41 mv
-190.44 186.73 ln
-214.16 186.73 ln
-st
-/Helvetica reencodeISO
-8 scalefont
-setfont
-221.36 186.73 mv
-(Brazil) sh
-np
-191.89 132.94 mv
-199.42 128.71 ln
-214.16 128.71 ln
-st
-221.36 128.71 mv
-(Columbia) sh
-np
-147.51 114.56 mv
-145.18 106.24 ln
-101.84 106.24 ln
-st
--769.36 106.24 mv 864.00 (Costa Rica) rjust
-(Costa Rica) sh
-np
-119.32 155.98 mv
-110.73 156.86 ln
-101.84 156.86 ln
-st
--769.36 156.86 mv 864.00 (Guatemala) rjust
-(Guatemala) sh
-np
-142.51 187.66 mv
-139.07 195.59 ln
-101.84 195.59 ln
-st
--769.36 195.59 mv 864.00 (Honduras) rjust
-(Honduras) sh
-end
ViewGit