Author: EvanCofsky
Date: 2008-04-21 02:06:36 -0400 (Mon, 21 Apr 2008)
New Revision: 1247

Modified:
   trunk/pysoy/examples/Widget/HeadsUp.py
   trunk/pysoy/examples/Widget/Interfaces.py
   trunk/pysoy/examples/Widget/main.py
Log:
Ticket #894: Cleaned up Stack demo.  Added more color effects.  Moved
taskset before loading PySoy modules to fix crashing.



Modified: trunk/pysoy/examples/Widget/HeadsUp.py
===================================================================
--- trunk/pysoy/examples/Widget/HeadsUp.py      2008-04-20 20:15:10 UTC (rev 
1246)
+++ trunk/pysoy/examples/Widget/HeadsUp.py      2008-04-21 06:06:36 UTC (rev 
1247)
@@ -45,6 +45,16 @@
 
     textColor = property(getTextColor, setTextColor)
     
+    def getLabelColor(self):
+        """The RGB floats of the current text color."""
+
+        return self._labelTexture.foreground.floats
+
+    def setLabelColor(self, color):
+        self._labelTexture.foreground = soy.colors.Color(color)
+
+    labelColor = property(getLabelColor, setLabelColor)
+    
     def getLabel(self):
         """The label displayed in the label field."""
 
@@ -135,14 +145,20 @@
                  labelFont = "DejaVu Sans", textFont = "DejaVu Sans"):
 
         width, height = self.size
-        margin = [140, 0, 0, 125]
+
         self.directions = LabeledText(self,
-                                      margin = margin,
-                                      label = "To Quit",
-                                      text = "Hit ESC")
+                                      label = "To Quit:",
+                                      text = "Hit ESC",
+                                      margin = (height * 27 / 100, 0, 0, width 
* 20 / 100))
 
         self.directions.textColor = [random() for c in range(3)]
 
+        self.labelColor = 1.0
+        self.labelAlpha = 1.0
+        self.labelColorAdd = 0.05
+        
+        self.update()
+        
     def update(self):
         color = []
 
@@ -152,6 +168,12 @@
                 c = random()
             color.append(c)
         self.directions.textColor = color
+
+        self.labelColor += self.labelColorAdd
+        if self.labelColor >= 1 or self.labelColor <= 0:
+            self.labelColorAdd = -self.labelColorAdd
+            self.labelColor = self.labelColor + 2 * self.labelColorAdd
+        self.directions.labelColor = (self.labelColor, self.labelAlpha)
         
 class HeadsUp(Example):
     """A simple Heads-Up Display example.

Modified: trunk/pysoy/examples/Widget/Interfaces.py
===================================================================
--- trunk/pysoy/examples/Widget/Interfaces.py   2008-04-20 20:15:10 UTC (rev 
1246)
+++ trunk/pysoy/examples/Widget/Interfaces.py   2008-04-21 06:06:36 UTC (rev 
1247)
@@ -19,7 +19,7 @@
     The class docstring is displayed to the user by L{main} when it
     presents the available examples."""
 
-    def __init__(self, frameRate = 10.0):
+    def __init__(self, frameRate = 45.0):
         """Initializes the attributes and the frame length for this
         example."""
         

Modified: trunk/pysoy/examples/Widget/main.py
===================================================================
--- trunk/pysoy/examples/Widget/main.py 2008-04-20 20:15:10 UTC (rev 1246)
+++ trunk/pysoy/examples/Widget/main.py 2008-04-21 06:06:36 UTC (rev 1247)
@@ -6,7 +6,18 @@
 import os.path
 import subprocess
 
-from time import sleep
+def taskset():
+    """Tries to set our CPU affinity using taskset.  This should not
+    be necessary once mill is working."""
+
+    pid = os.getpid()
+    try:
+        c = subprocess.check_call(['taskset', '-p', '1', '%d' % os.getpid()])
+    except subprocess.CalledProcessError, e:
+        sys.stderr.write("Could not set CPU affinity (taskset returned %d).  
Example may crash." % e.returncode)
+
+taskset()
+
 from textwrap import TextWrapper
 
 import soy
@@ -52,19 +63,7 @@
     sys.stderr.write('\n')
     sys.exit(1)
 
-def taskset():
-    """Tries to set our CPU affinity using taskset.  This should not
-    be necessary once mill is working."""
-
-    pid = os.getpid()
-    try:
-        c = subprocess.check_call(['taskset', '-p', '1', '%d' % os.getpid()])
-    except subprocess.CalledProcessError, e:
-        sys.stderr.write("Could not set CPU affinity (taskset returned %d).  
Example may crash." % e.returncode)
-
 def main(examples, *names):
-    taskset()
-    
     try:
         exampleName = names[0]
     except IndexError:

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to