pySimBlocks.gui.graphics.port_item

class pySimBlocks.gui.graphics.port_item.PortItem(instance: PortInstance, parent_block: BlockItem)[source]

Bases: QGraphicsItem

Render and interact with a block port on the diagram.

instance

Port model represented by the item.

parent_block

Block item owning the port.

label

Text label displayed next to the port.

MARGIN = 4
R = 6
L = 15
H = 10
RECT = PySide6.QtCore.QRectF(-8.000000, -8.000000, 15.000000, 15.000000)
property is_input

Return whether this port is an input port.

property is_on_left_side: bool

Return whether the port is currently placed on the left block side.

update_label_position()[source]

Position the port label according to the current side.

update_display_as()[source]

Refresh the displayed port label text.

connection_anchor() QPointF[source]

Return the scene anchor point used to attach a connection.

Returns:

Scene coordinate used as the wire anchor for this port.

is_compatible(other: PortItem)[source]

Return whether this port can connect to another port.

Parameters:

other – Other port item to compare against.

Returns:

True if the ports have opposite directions.

boundingRect() QRectF[source]

Return the fixed bounding rectangle of the port.

Returns:

Bounding rectangle used for painting and hit testing.

paint(painter, option, widget=None)[source]

Paint the port as a circle or triangle depending on its direction.

Parameters:
  • painter – Painter used to render the item.

  • option – Style option describing the current paint state.

  • widget – Optional target widget.

shape()[source]

Return the hit-test shape of the port.

Returns:

Painter path matching the painted port shape.

mousePressEvent(event)[source]

Start a connection drag from this port.

Parameters:

event – Qt mouse-press event.

itemChange(change, value)[source]

Update the label position when the port scene position changes.

Parameters:
  • change – Item change identifier.

  • value – Proposed new value for the change.

Returns:

Base implementation result.