Bug on block without input or output fixed
authorlbessard
Fri, 05 Oct 2007 17:59:34 +0200
changeset 103 26c10e28ee3a
parent 102 85875dcb7754
child 104 a9b8916d906d
Bug on block without input or output fixed
graphics/FBD_Objects.py
--- a/graphics/FBD_Objects.py	Tue Oct 02 18:07:59 2007 +0200
+++ b/graphics/FBD_Objects.py	Fri Oct 05 17:59:34 2007 +0200
@@ -92,17 +92,18 @@
     def RefreshConnectors(self):
         # Calculate the size for the connector lines
         lines = max(len(self.Inputs), len(self.Outputs))
-        linesize = max((self.Size[1] - BLOCK_LINE_SIZE) / lines, BLOCK_LINE_SIZE)
-        # Update inputs positions
-        position = BLOCK_LINE_SIZE + linesize / 2
-        for input in self.Inputs:
-            input.SetPosition(wx.Point(0, position))
-            position += linesize
-        # Update outputs positions
-        position = BLOCK_LINE_SIZE + linesize / 2
-        for output in self.Outputs:
-            output.SetPosition(wx.Point(self.Size[0], position))
-            position += linesize
+        if lines > 0:
+            linesize = max((self.Size[1] - BLOCK_LINE_SIZE) / lines, BLOCK_LINE_SIZE)
+            # Update inputs positions
+            position = BLOCK_LINE_SIZE + linesize / 2
+            for input in self.Inputs:
+                input.SetPosition(wx.Point(0, position))
+                position += linesize
+            # Update outputs positions
+            position = BLOCK_LINE_SIZE + linesize / 2
+            for output in self.Outputs:
+                output.SetPosition(wx.Point(self.Size[0], position))
+                position += linesize
         self.RefreshConnected()
     
     # Refresh the positions of wires connected to inputs and outputs