Commits

Sven Hendriks  committed 905eabc

Beautified code a bit.

  • Participants
  • Parent commits 1de6c83

Comments (0)

Files changed (1)

File lyne/gui/itemwidget.py

 # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
 from Tkinter import *
 
+
 class ItemWidget(object):
     ''' Abstract ItemWidget class.
     '''
         self._create_components()
 
     def _create_components(self):
-        self.canvas.create_rectangle((self.x, self.y, self.x+self.width-1, self.y+self.height-1), fill='black')
+        self.canvas.create_rectangle(
+            (self.x, self.y, self.x+self.width-1,
+             self.y+self.height-1), fill='black')
+
 
 class ConstantItemWidget(ItemWidget):
     ''' A widget representing a constant integer with one output.
         self._create_components()
 
     def _create_components(self):
-        self.canvas.create_rectangle((self.x, self.y, self.x+self.width-1, self.y+self.height-1), fill='gray')
-        self.canvas.create_text((self.x+1, self.y+1), text=str(self.value), anchor='nw')
+        self.canvas.create_rectangle(
+            (self.x, self.y, self.x+self.width-1, self.y+self.height-1),
+            fill='gray')
+        self.canvas.create_text(
+            (self.x+1, self.y+1), text=str(self.value), anchor='nw')
 
         self.output = self.canvas.create_rectangle(
-            (self.x+(self.width/2 - 3), self.y+self.height-2, self.x+(self.width/2 + 3), self.y+self.height+3), 
+            (self.x+(self.width/2 - 3), self.y+self.height-2,
+             self.x+(self.width/2 + 3), self.y+self.height+3), 
             fill='green'
         )
 
-        #Widget.bind(self.output, '<Button-1>', self.canvas.handle_click_in_item)
 
 class CounterItemWidget(ItemWidget):
     ''' A widget representing an integer counting up with one output.
     '''
     def _create_components(self):
-        self.canvas.create_rectangle((self.x, self.y, self.x+self.width-1, self.y+self.height-1), fill='lightblue')
-        self.canvas.create_rectangle((self.x+(self.width/2 - 3), self.y+self.height-2, self.x+(self.width/2 + 3), self.y+self.height+3), fill='green')
+        self.canvas.create_rectangle(
+            (self.x, self.y, self.x+self.width-1,
+             self.y+self.height-1), fill='lightblue')
+        self.canvas.create_rectangle(
+            (self.x+(self.width/2 - 3), self.y+self.height-2,
+             self.x+(self.width/2 + 3), self.y+self.height+3), fill='green')
         self.canvas.create_text((self.x+1, self.y+1), text='t++', anchor='nw')
 
+
 class OperatorItemWidget(ItemWidget):
     ''' An abstract operator widget with two inputs and one output.
     '''
     def _create_components(self):
-        self.canvas.create_rectangle((self.x, self.y, self.x+self.width-1, self.y+self.height-1), fill='orange')
-        self.canvas.create_rectangle((self.x+(self.width/2 - 3), self.y+self.height-2, self.x+(self.width/2 + 3), self.y+self.height+3), fill='green')
-        self.canvas.create_rectangle((self.x+(self.width/3.0 - 3), self.y-3, self.x+(self.width/3.0 + 3), self.y+2), fill='green')
-        self.canvas.create_rectangle((self.x+(self.width*(2/3.0) - 3), self.y-3, self.x+(self.width*(2/3.0) + 3), self.y+2), fill='green')
+        self.canvas.create_rectangle(
+            (self.x, self.y, self.x+self.width-1,
+             self.y+self.height-1), fill='orange')
+        self.canvas.create_rectangle(
+            (self.x+(self.width/2 - 3), self.y+self.height-2,
+             self.x+(self.width/2 + 3), self.y+self.height+3), fill='green')
+        self.canvas.create_rectangle(
+            (self.x+(self.width/3.0 - 3), self.y-3,
+             self.x+(self.width/3.0 + 3), self.y+2), fill='green')
+        self.canvas.create_rectangle(
+            (self.x+(self.width*(2/3.0) - 3), self.y-3,
+             self.x+(self.width*(2/3.0) + 3), self.y+2), fill='green')
+
 
 class ANDOperatorItemWidget(OperatorItemWidget):
     ''' A bitwise AND operator widget with two inputs and one output.
         OperatorItemWidget._create_components(self)
         self.canvas.create_text((self.x+1, self.y+1), text='|', anchor='nw')
 
+
 class XOROperatorItemWidget(OperatorItemWidget):
     ''' A bitwise XOR operator widget with two inputs and one output.
     '''
         OperatorItemWidget._create_components(self)
         self.canvas.create_text((self.x+1, self.y+1), text='XOR', anchor='nw')
 
+
 class NOTOperatorItemWidget(OperatorItemWidget):
     ''' A bitwise NOT operator widget with two inputs and one output.
     '''
         OperatorItemWidget._create_components(self)
         self.canvas.create_text((self.x+1, self.y+1), text='^', anchor='nw')
 
+
 class RightShiftOperatorWidget(OperatorItemWidget):
     ''' A right shift operator widget with two inputs and one output.
     '''
         OperatorItemWidget._create_components(self)
         self.canvas.create_text((self.x+1, self.y+1), text='>>', anchor='nw')
 
+
 class LeftShiftOperatorWidget(OperatorItemWidget):
     ''' A left shift operator widget with two inputs and one output.
     '''
         OperatorItemWidget._create_components(self)
         self.canvas.create_text((self.x+1, self.y+1), text='<<', anchor='nw')
 
+
 class SinkItemWidget(ItemWidget):
     ''' A sink item widget representing "the speaker" with one input.
     '''
     def _create_components(self):
-        self.canvas.create_rectangle((self.x, self.y, self.x+self.width-1, self.y+self.height-1), fill='yellow')
-        self.canvas.create_rectangle((self.x+(self.width/2 - 3), self.y-3, self.x+(self.width/2 + 3), self.y+2), fill='green')
+        self.canvas.create_rectangle(
+            (self.x, self.y, self.x+self.width-1,
+             self.y+self.height-1), fill='yellow')
+        self.canvas.create_rectangle(
+            (self.x+(self.width/2 - 3), self.y-3,
+             self.x+(self.width/2 + 3), self.y+2), fill='green')
         self.canvas.create_text((self.x+1, self.y+1), text='Sink', anchor='nw')
 
-