Esempio n. 1
0
    def __init__(self,
                 x,
                 y,
                 width=200,
                 height=80,
                 name=None,
                 focus=True,
                 line_width=3.5,
                 **kwargs):
        super(VariableItem, self).__init__(**kwargs)
        self.x = int(x - width / 2)
        self.y = int(y - height / 2)
        self.width = width
        self.height = height
        self.__needs_resize_calc = True
        self.dragging = False
        self.active_color = [0, 0, 0]
        self.__old_name = ""
        self.named = True

        self._new = True
        # this will be the variable created in the simulator
        self.var = None

        self.line_width = line_width

        text_width = self.width - self.padding * 2 - self.icon_size

        if name is not None:
            self._display_name = TextInfo(name,
                                          wrap_width=text_width,
                                          align=pango.ALIGN_LEFT,
                                          placeholder_text=False)
        else:
            self._display_name = TextInfo("(enter name)",
                                          wrap_width=text_width,
                                          align=pango.ALIGN_LEFT,
                                          placeholder_text=True)

        if focus:
            self.get_canvas().grab_focus(self)
            self.get_canvas().grab_highlight(self)
Esempio n. 2
0
  def __init__(self, x, y, width=140, height=80, name=None,
               focus=True, line_width=3.5, **kwargs):
    super(StockItem, self).__init__(**kwargs)

    self._new = True
    # this will be the variable created in the simulator
    self.var = None

    self.x = int(x - width/2)
    self.y = int(y - height/2)
    self.width = width
    self.height = height
    self.dragging = False

    self.active_color = [0, 0, 0]
    self.line_width = line_width
    self.__old_name = ""
    self.named = True

    # keep track of inflows and outflows, for use in engine
    self.inflows = []
    self.outflows = []

    text_width = self.width - self.padding*2

    if name is not None:
      self._display_name = TextInfo(name, wrap_width=text_width, 
                                    placeholder_text=False)
    else:
      self._display_name = TextInfo("(enter name)", wrap_width=text_width, 
                                    placeholder_text=True)

    self.__needs_resize_calc = True

    if focus:
      self.get_canvas().grab_focus(self)
      self.get_canvas().grab_highlight(self)