Commits

Nick Raptis  committed 04253ea

Some whitespace cleanup

  • Participants
  • Parent commits a476de6

Comments (0)

Files changed (11)

File duixer/ui/Connection.py

         print 'Firmata Version:', self.Board.firmata_version
         print 'Firmware:', self.Board.firmware, self.Board.firmata_version
         self.bindEvent(MixerOutEvent, self.onMixerOutEvent)
-
+    
     def findBoard(self):
         if not 'win' in sys.platform:
             try:
     def reset(self):
         for pinNo, pinObj in self.Pins.items():
             pinObj.write(0)
-        
     
     def onMixerOutEvent(self, evt):
         #print evt.EventData
             else:
                 self.Pins[evt.Pin].write(0.0)
     
-                
+
 
 class _testForm(_testFormBase):
     def beforeInit(self):
         self._testPin = dDigitalPin
         self._testPinNo = 13
         self._size = (140,160)
-
+    
     def afterInitAll(self):
         class dummy(object):
             pass
         self.Mixer.Pins = {13: self.Pin}
         self.con = Connection(Parent=self)
         self.con.setupPins(self.Mixer.Pins)
-        
+    
     def onPanelOutEvent(self, evt):
         #print "OUT:", evt.__dict__
         self.reraiseEvent(evt, self.con, MixerOutEvent)

File duixer/ui/Events.py

 class PinEvent(dEvent):
     def _getPin(self):
         return self.EventData.get('Pin', None)
-
+    
     def _getValue(self):
         return self.EventData.get('Value', None)
-
+    
     def _getAnalog(self):
         return self.EventData.get('Analog', None)
-
+    
     def _getOn(self):
         return self.EventData.get('On', None)
-
+    
     Pin = property(_getPin, None, None)
     Value = property(_getValue, None, None)
     Analog = property(_getAnalog, None, None)

File duixer/ui/Group.py

 class Group(dabo.dObject.dObject, MixIn):
     def initProperties(self):
         self.Pins = []
-        
+    
     def afterInit(self):
         self.bindEvent(PanelOutEvent, self.onPanelOutEvent)
     
             self.reraiseEvent(evt)
             if not pin == src:
                 self.reraiseEvent(evt, self.Parent.Pins[pin], PanelUpdateEvent)
-                
+    
     def registerPin(self, Pin):
         if not Pin in self.Pins:
             self.Pins.append(Pin)
-
+    
     def removePin(self, Pin):
         if Pin in self.Pins:
             self.Pins.remove(Pin)
         self.appendItem(GroupMenuItem(self, Tag=None, Caption="No Group"))
         for grp in self.Parent.Parent.Groups:
             self.appendItem(GroupMenuItem(self, Tag=grp, Caption=grp.Name))
-
+    
     def afterInitAll(self):
         """Needed because dabo only autobinds first Item"""
         for c in self.Children:
         pnl = _testPanel(self)
         self.Pins = {1: pnl, 2: pnl, 3: pnl}
         self.Sizer.append1x(pnl)
-
+    
     def afterInitAll(self):
         self.Size = (500,500)
         self.update()
         self.Sizer = dabo.ui.dSizer("v")
         self.Sizer.append1x(self.Txt)
         self.Sizer.append(self.Lbl, "x")
-
+    
     def afterInitAll(self):
         dabo.ui.callAfterInterval(2000, self.runTests)
-        
+    
     def initEvents(self):
         self.bindEvent(PanelOutEvent, self.onPanelOutEvent)
         self.bindEvent(PanelUpdateEvent, self.onPanelUpdateEvent)
         EventData = {'Pin': 1, 'Value': 10}
         self.Group.raiseEvent(PanelOutEvent, **EventData)
         self.update()
-        
+    
     def onPanelOutEvent(self, evt):
         evt.EventData.pop('timestamp')
         self.Txt.Value += "Mixer got Event for pin %s: %s\n" % (evt.Pin, evt.EventData)
         self.update()
-        
+    
     def onPanelUpdateEvent(self, evt):
         evt.EventData.pop('timestamp')
         self.Txt.Value += "Panel %s got Update Event: %s\n" % (evt.Pin, evt.EventData)
         self.update()
-
+    
     def onMouseRightClick(self, evt):
         self.showContextMenu(GroupMenu(self), release=True)
 

File duixer/ui/Random.py

         self.Min = 0
         self.Max = 255
         self.Interval = 1000
-
+    
     def onHit(self, evt):
         self.generate()
-
+    
     def generate(self):
         if self.Pin.Analog and self.Analog:
             self.Pin.raiseEvent(ChildEvent,
         else:
             self.Pin.raiseEvent(ChildEvent,
                 On=random.choice([True, False]))
-        
+    
     def _setMin(self, val):
         self._min = max(val, 0)
-        
+    
     def _getMin(self):
         return self._min
-
+    
     def _setMax(self, val):
         self._max = min(val, 255)
-        
+    
     def _getMax(self):
         return self._max
     
     def _setInt(self, val):
         self.Interval = val * 1000
-        
+    
     def _getInt(self):
         return self.Interval / 1000
     
     
     def initProperties(self):
         self.MinimumSize = (16,12)
-        
+    
     def onHit(self, evt):
         r=self.Parent.Random
         if not r.isRunning():
     
     def onMouseLeftClick(self, evt):
         self.raiseEvent(dabo.dEvents.Hit)
-
+    
     def onHit(self, evt):
         if not self._panel:
             self._panel = rPanel(self.Parent)
         else:
             self.Parent.Sizer.remove(self._panel, destroy=True)
         self.Parent.layout()
-
+    
     def onMouseRightClick(self, evt):
         self.showContextMenu(RandomMenu(self.Parent), release=True)
-
     
 
 
         s.append(grid, "x")
         s.append(rOkButton(self), "x")
         s.append(rCancel(self), "x")
-
+    
     def onHit(self, evt):
         if evt.EventData['Confirm']:
             r = self.Parent.Random
             #print "First"
             dabo.ui.callAfterInterval(100, self.setFocus)
             #dabo.ui.callAfterInterval(100, self.select, 0, -1)
-
+    
     def initProperties(self):
         self.Max = 255
     
     def __init__(self, parent, target, *args, **kargs):
         self.Target = target
         super(rCopyButton, self).__init__(parent, *args, **kargs)
-
+    
     def initProperties(self):
         self.Caption = "Copy"
         self.MinimumWidth = 44
     
     def afterInitAll(self):
         self.Random = Random(self)
-
+    
     def initProperties(self):
         self.Analog = True
         self.Value = 100
     
     def initEvents(self):
         self.bindEvent(ChildEvent, self.onChildEvent)
-
+    
     def onChildEvent(self, evt):
         if evt.On is not None:
             print "On:", evt.On
             print "Value(%s,%s):" % (self.Random.Min, self.Random.Max), evt.Value
             return
         print "Empty Event?"
-
+    
     def onHit(self, evt):
         self.Analog = not self.Analog
         self.Random.release()
         self.Random = Random(self)
-
+    
     def onMouseRightClick(self, evt):
         self.showContextMenu(RandomMenu(self), release=True)
 

File duixer/ui/dAnalogPin.py

         
         #sizers
         analogs = dabo.ui.dSizer("h")
-
+        
         #layout
         self.Sizer.prepend(analogs, "x", 1)
         self.Sizer.insert(1, spinner, "x")
         analogs.append(gauge, "x", 2, border=14, borderSides=("top", "bottom"))
         analogs.append(slider, "x", 1)
-
+        
         self.MinimumSize=(100,200)
-
+    
     def initProperties(self):
         self.Analog = True
         self.On = True

File duixer/ui/dDigitalPin.py

 class dDigitalPin(dPinBase):
     def afterInit(self):
         pass
-
+    
     def initProperties(self):
         self._updateable = ['On']
     
         self._testPin = dDigitalPin
         self._testPinNo = 13
         self._size = (140,160)
-        
+
 if __name__ == "__main__":
     app = dabo.dApp(MainFormClass=_testForm)
     app.start()

File duixer/ui/dMixerBase.py

     def initProperties(self):
         self.Pins = {}
         self.Groups = []
-
+    
     def initEvents(self):
         self.bindEvent(PanelOutEvent, self.onPanelOutEvent)
-
+    
     def afterInit(self):
         self.Sizer = dabo.ui.dSizer("h")
         self.VSizer = dabo.ui.dSizer("v")
         self.Caption = u"dμixer test Mixer ;)"
         pnl = _testMixer(self)
         self.Sizer.append1x(pnl)
-
+    
     def afterInitAll(self):
         self.Size = (600,550)
         self.update()
-
+    
     def initEvents(self):
         self.bindEvent(MixerOutEvent, self.onMixerOutEvent)
-
+    
     def onMixerOutEvent(self, evt):
         print evt.EventData
 

File duixer/ui/dPinBase.py

         self.On = False
         self._updateable = []
         super(dPinBase, self)._initProperties()
-        
+    
     def _afterInit(self):
         self.Random = Random(self)
         self.Group = None
         vs = dabo.ui.dSizer("v")
         self.Sizer = dabo.ui.dBorderSizer(nBox(self), "v")
         options = dabo.ui.dSizer("h")
-
+        
         #labels
         onlabel = dabo.ui.dLabel(self, Caption="ON", FontSize=8)
         rnlabel = rLabel(self, Caption="RND", FontSize=6)
         options.append(rnlabel, valign="Middle")
         options.append(random, "x")
         options.appendSpacer(0, 1)
-
+        
         self.MinimumSize=(100,100)
         super(dPinBase, self)._afterInit()
         #expand if subclass added no other objects
         expand = not self.Sizer.ChildObjects
         self.Sizer.append(vs, "x", expand)
         self.Sizer.layout()
-
+    
     def initEvents(self):
         self.bindEvent(ChildEvent, self.onChildEvent)
         self.bindEvent(PanelChangeEvent, self.onChildEvent)
             if value is not None:
                 setattr(self, name, value)
         self.update()
-        
+    
     def getName(self):
         return self.Name
     
                         Pin=self._testPinNo, Name=self._testPin.__name__)
         self.Sizer.append1x(self.Pin)
         self.Groups = [Group(Parent=self, Name="Group")]
-
+    
     def afterInitAll(self):
         self.Size = self._size
         self.update()
-
+    
     def initEvents(self):
         self.bindEvent(PanelOutEvent, self.onPanelOutEvent)
     
     def onPanelOutEvent(self, evt):
         print "OUT:", evt.__dict__
         self.reraiseEvent(evt, self.Pin, PanelUpdateEvent)
-        
+
 if __name__ == "__main__":
     app = dabo.dApp(MainFormClass=_testFormBase)
     app.start()

File duixer/ui/mainForm.py

         
     def afterInitAll(self):
         self.Connection.setupPins(self.Mixer.Pins)
-        
+    
     def initEvents(self):
         self.bindEvent(MixerOutEvent, self.onMixerOutEvent)
-        
+    
     def onMixerOutEvent(self, evt):
         self.reraiseEvent(evt, self.Connection)
+    
+
 
 class _testForm(mainForm):
     def afterInit(self):
             pinDict = {'Analog': False, 'Pin': pn, 'Name': "Pin %d"%pn}
             mixer.addPin(pinDict)
         self.layout()
-    
 
-        
 if __name__ == "__main__":
     app = dabo.dApp(MainFormClass=_testForm)
     app.start()

File duixer/ui/nBox.py

 import dabo
 dabo.ui.loadUI("wx")
 
-
 class nBox(dabo.ui.dBox):
     """This is the actual box that you need to pass to the sizer"""
     def initProperties(self):
     
     def afterInitAll(self):
         self.DynamicCaption = self.Parent.getName
-
+    
     def onMouseLeftClick(self, evt):
         #TODO: Get some positioning too
         self.raiseEvent(dabo.dEvents.Hit)
-
+    
     def onHit(self, evt):
         if not self._panel:
             self._panel = nPanel(self.Parent)
         else:
             self.Parent.Sizer.remove(self._panel, destroy=True)
         self.Parent.layout()
-        
+    
     def onMouseRightClick(self, evt):
         self.showContextMenu(NameMenu(self.Parent), release=True)
-
+    
 
 
 class NameMenu(dabo.ui.dMenu):
         s.append(nTextBox(self), "x")
         s.append(nButton(self), "x")
         s.append(nCancel(self), "x")
-
+    
     def onHit(self, evt):
         if evt.EventData['Confirm']:
             self.Parent.Name = self.nTextBox.Value
             self.Parent.update()
         self.Parent.nBox.raiseEvent(dabo.dEvents.Hit)
-
+    
 
 
 class nTextBox(dabo.ui.dTextBox):
     
     def onHit(self, evt):
         self.Parent.raiseEvent(dabo.dEvents.Hit, Confirm = True)
-
+    
 
 
 class nCancel(dabo.ui.dButton):
     
     def onHit(self, evt):
         self.Parent.raiseEvent(dabo.dEvents.Hit, Confirm = False)
-
+    
 
 
 class _testForm(dabo.ui.dForm):
         vs = self.Sizer = dabo.ui.dBorderSizer(nBox(self), "v")
         hs.append1x(vs)
         vs.append1x(dabo.ui.dEditBox(self, Value=
-                        "Press the name to change it.\nButtons should appear above"))
+                "Press the name to change it.\nButtons should appear above"))
     
     def initProperties(self):
         self.Name = "Foo"
-        
+    
     def getName(self):
         return self.Name
 

File duixer/ui/sControls.py

 
 class sMixIn(MixIn):
     """Common Methods for slave Controls"""
-
+    
     def onMouseRightClick(self, evt):
         """Used so we can have a common Context Menu"""
         self.reraiseEvent(evt)
     """slave Gauge
     If you want a vertical Gauge, just set Orientation='v' while constructing
     This class does not respond to user interaction and doesn't raise any Events"""
-
+    
     def initProperties(self):
         self.Range = 255
-        
+    
     def afterInitAll(self):
         self.DynamicValue = self.getValue
         self.DynamicEnabled = self.amEnabled
-
+    
     def getValue(self, value=None):
         """Return 0 if not Enabled, else report the Parent's value."""
         if self.amEnabled():
     
     def amEnabled(self):
         return self.Parent.On    
+    
 
 
 class sLed(dabo.ui.dLed, sMixIn):
     """slave Led
     This class does not respond to user interaction and doesn't raise any Events"""
-
+    
     def initProperties(self):
         self.OffColor = 'black'
         self._inUpdate2 = False #part of the update hack
-        
+    
     def update(self):
         """Dabo doesn't give us DynamicProperties for dLed,
         so we're hacking it here."""
             return self.gradient(self.Parent.Value)
         else:
             return (255, 0, 0)
-        
+    
     def gradient(self, val):
         divgreen, divyellow, divred = 128, 192, 240
         if val < divyellow:
         else:
             red = 255
         return (red, green, 0)
-        
+    
     def mapValue(self, value, minIn, maxIn, minOut=0, maxOut=255):
         """Map a value from the range minIn,maxIn to the range minOut,maxOut"""
         return (value-minIn)*(maxOut-minOut)/(maxIn-minIn)+minOut
     
     def onResize(self, evt):
         self.refresh()
-        
+    
 
 
 class sOnButton(dabo.ui.dButton, sMixIn):
     
     def afterInitAll(self):
         self.DynamicCaption = self.getCaption
-        
+    
     def getCaption(self):
         if self.Parent.On:
             return 'On'
         else:
             return 'Off'
-
+    
     def onHit(self, evt):
         self.Parent.raiseEvent(ChildEvent, On=(not self.Parent.On))
     
     def initProperties(self):
         self.Max = 255
         self.Continuous = True
-        
+    
     def afterInitAll(self):
         self.DynamicValue = self.normValue
-
+    
     def normValue(self, value=None):
         """Because of a glitch in wx, vertical sliders don't reverse properly.
         Pass a value here to get its normalized value or call without one
     
     def initProperties(self):
         self.Max = 255
-        
+    
     def afterInitAll(self):
         self.DynamicValue = self.getValue
-
+    
     def getValue(self, value=None):
         return self.Parent.Value
-
+    
     def onKeyChar(self, evt):
         #Update value on Return key
         if evt.keyChar == "\r":
             self.onInteractiveChange(evt)
-
+    
     def onInteractiveChange(self, evt):
         #Call with an Interval so we don't generate events for continuous mouse down
         dabo.ui.callAfterInterval(200,
             self.Parent.raiseEvent, ChildEvent, Value=self.Value)
-        
+    
 
 
 class _testForm(dabo.ui.dForm):
         hs.append1x(sLed(self))
         hs.append1x(sOnButton(self))
         vs.append1x(hs)
-
     
     def initProperties(self):
         self.Value = 0
         if evt.On is not None:
             self.On = evt.On
         self.update()
-
+    
     def onMouseRightClick(self, evt):
         print evt.__dict__
         self.showContextMenu(dabo.ui.dMenu(), release=True)