Пример #1
0
 def _draw_connector(self, canvas, point, enabled=True):
   """
   |point|: a tuple of the form (x, y) indicating where the connecter should
       be drawn.
   |enabled|: allowed to start and end wires at the connector being created?
   Draws and returns a connector for this Drawable at the indicated |point|.
   """
   x, y = map(snap, point)
   connector = Connector(create_connector(canvas, x, y, CONNECTOR_EMPTY_COLOR
       if enabled else CONNECTOR_DISABLED_COLOR, CONNECTOR_EMPTY_OUTLINE if
       enabled else CONNECTOR_DISABLED_OUTLINE, 2 if enabled else 1), (x, y),
       self, enabled)
   self.connectors.add(connector)
   return connector
Пример #2
0
 def redraw(self, canvas):
   """
   Redraws this connector, most importantly to mark/color it connected or not
       connected.
   """
   canvas.delete(self.canvas_id)
   x, y = self.center
   # appropriately choose fill color
   fill = ((CONNECTOR_FULL_COLOR if self.num_wires() else
       CONNECTOR_EMPTY_COLOR) if self.enabled else CONNECTOR_DISABLED_COLOR)
   outline = ((CONNECTOR_FULL_OUTLINE if self.num_wires() else
       CONNECTOR_EMPTY_OUTLINE) if self.enabled else
       CONNECTOR_DISABLED_OUTLINE)
   active_width = 2 if self.enabled else 1
   self.canvas_id = create_connector(canvas, x, y, fill, outline,
       active_width)