Commits

Sven Hendriks committed 1c1abc3

Removed code just beautified b/c it was dead wood :-)

  • Participants
  • Parent commits 905eabc

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.
-    '''
-    width = 40
-    height = 20
-
-    inputs = None
-    output = None
-
-    def __init__(self, canvas, x, y):
-        self.canvas = canvas
-        self.x = x
-        self.y = y
-        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')
-
-
-class ConstantItemWidget(ItemWidget):
-    ''' A widget representing a constant integer with one output.
-    '''
-    def __init__(self, canvas, x, y, value=0):
-        if not isinstance(value, int):
-            raise ValueError, 'value must be an integer, not %r' % (value,)
-        self.value = value
-        ItemWidget.__init__(self, canvas, x, y)
-        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.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), 
-            fill='green'
-        )
-
-
-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_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')
-
-
-class ANDOperatorItemWidget(OperatorItemWidget):
-    ''' A bitwise AND operator widget with two inputs and one output.
-    '''
-    def _create_components(self):
-        OperatorItemWidget._create_components(self)
-        self.canvas.create_text((self.x+1, self.y+1), text='&', anchor='nw')
-
-
-class OROperatorItemWidget(OperatorItemWidget):
-    ''' A bitwise OR operator widget with two inputs and one output.
-    '''
-    def _create_components(self):
-        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.
-    '''
-    def _create_components(self):
-        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.
-    '''
-    def _create_components(self):
-        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.
-    '''
-    def _create_components(self):
-        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.
-    '''
-    def _create_components(self):
-        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_text((self.x+1, self.y+1), text='Sink', anchor='nw')
-