Example #1
0
 def mousePressEvent(self, event):
     if event.button() == QtCore.Qt.MouseButton.LeftButton:
         start = PortItem().boundingRect().width()
         end = self.boundingRect().width() - start
         x_pos = event.pos().x()
         if not start <= x_pos <= end:
             event.ignore()
     super(NodeItem, self).mousePressEvent(event)
Example #2
0
    def add_output(self, name='output', multi_port=False, display_name=True):
        """
        Args:
            name (str): name for the port.
            multi_port (bool): allow multiple connections.
            display_name (bool): display the port name.

        Returns:
            PortItem: output item widget
        """
        port = PortItem(self)
        port.name = name
        port.port_type = OUT_PORT
        port.multi_connection = multi_port
        port.display_name = display_name
        text = QGraphicsTextItem(port.name, self)
        text.font().setPointSize(8)
        text.setFont(text.font())
        text.setVisible(display_name)
        self._output_items[port] = text
        if self.scene():
            self.post_init()
        return port