spinetoolbox.project_item_icon

Classes for drawing graphics items on QGraphicsScene.

Module Contents

Classes

ProjectItemIcon

Base class for project item icons drawn in Design View.

ConnectorButton

Connector button graphics item. Used for Link drawing between project items.

ExecutionIcon

An icon to show information about the item's execution.

ExclamationIcon

An icon to notify that a ProjectItem is missing some configuration.

RankIcon

An icon to show the rank of a ProjectItem within its DAG.

class spinetoolbox.project_item_icon.ProjectItemIcon(toolbox, icon_file, icon_color)[source]

Bases: PySide6.QtWidgets.QGraphicsPathItem

Base class for project item icons drawn in Design View.

Parameters
  • toolbox (ToolboxUI) – QMainWindow instance

  • icon_file (str) – Path to icon resource

  • icon_color (QColor) – Icon’s color

ITEM_EXTENT = 64[source]
FONT_SIZE_PIXELS = 12[source]
add_specification_icon(spec_icon_path)[source]

Adds an SVG icon to bottom left corner of the item icon based on Tool Specification type.

Parameters

spec_icon_path (str) – Path to icon resource file.

remove_specification_icon()[source]

Removes the specification icon SVG from the scene.

rect()[source]
_update_path()[source]
update_path(rounded)[source]
_do_update_path(rounded)[source]
finalize(name, x, y)[source]

Names the icon and moves it by a given amount.

Parameters
  • name (str) – icon’s name

  • x (int) – horizontal offset

  • y (int) – vertical offset

_setup()[source]

Sets up item attributes.

name()[source]

Returns name of the item that is represented by this icon.

Returns

icon’s name

Return type

str

update_name_item(new_name)[source]

Sets a new text to name item.

Parameters

new_name (str) – icon’s name

set_name_attributes()[source]

Sets name item attributes (font, size, style, alignment).

_reposition_name_item()[source]

Sets name item position (centered on top of the master icon).

conn_button(position='left')[source]

Returns item’s connector button.

Parameters

position (str) – “left”, “right” or “bottom”

Returns

connector button

Return type

QWidget

Collects outgoing connection links.

Returns

outgoing links

Return type

list of LinkBase

Collects incoming connection links.

Returns

outgoing links

Return type

list of LinkBase

_closest_connector(pos)[source]

Returns the closest connector button to given scene pos.

Updates link drawer destination. If pos is None, then the link drawer would have no destination. Otherwise, the destination would be the connector button closest to pos.

hoverEnterEvent(event)[source]

Sets a drop shadow effect to icon when mouse enters its boundaries.

Parameters

event (QGraphicsSceneMouseEvent) – Event

hoverMoveEvent(event)[source]
hoverLeaveEvent(event)[source]

Disables the drop shadow when mouse leaves icon boundaries.

Parameters

event (QGraphicsSceneMouseEvent) – Event

mousePressEvent(event)[source]

Updates scene’s icon group.

Updates geometry of connected links to reflect this item’s most recent position.

mouseReleaseEvent(event)[source]

Clears pre-bump rects, and pushes a move icon command if necessary.

notify_item_move()[source]
contextMenuEvent(event)[source]

Show item context menu.

Parameters

event (QGraphicsSceneMouseEvent) – Mouse event

itemChange(change, value)[source]

Reacts to item removal and position changes.

In particular, destroys the drop shadow effect when the item is removed from a scene and keeps track of item’s movements on the scene.

Parameters
  • change (GraphicsItemChange) – a flag signalling the type of the change

  • value – a value related to the change

Returns

Whatever super() does with the value parameter

set_pos_without_bumping(pos)[source]

Sets position without bumping other items. Needed for undoing move operations.

Parameters

pos (QPointF) –

_handle_collisions()[source]

Handles collisions with other items.

make_room_for_item(other)[source]

Makes room for another item.

Parameters

item (ProjectItemIcon) –

_restablish_bumped_items()[source]

Moves bumped items back to their original position if no collision would happen anymore.

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

Sets a dashed pen if selected.

class spinetoolbox.project_item_icon.ConnectorButton(toolbox, parent, position='left')[source]

Bases: PySide6.QtWidgets.QGraphicsPathItem

Connector button graphics item. Used for Link drawing between project items.

Parameters
  • toolbox (ToolboxUI) – QMainWindow instance

  • parent (ProjectItemIcon) – parent graphics item

  • position (str) – Either “top”, “left”, “bottom”, or “right”

property parent[source]
brush[source]
hover_brush[source]
rect()[source]
update_path(parent_radius)[source]
parent_name()[source]

Returns project item name owning this connector button.

project_item()[source]

Returns the project item this connector button is attached to.

Returns

project item

Return type

ProjectItem

mousePressEvent(event)[source]

Connector button mouse press event.

Parameters

event (QGraphicsSceneMouseEvent) – Event

set_friend_connectors_enabled(enabled)[source]

Enables or disables all connectors in the parent.

This is called by LinkDrawer to disable invalid connectors while drawing and reenabling them back when done.

Parameters

enabled (bool) – True to enable connectors, False to disable

set_hover_brush()[source]
set_normal_brush()[source]
hoverEnterEvent(event)[source]

Sets a darker shade to connector button when mouse enters its boundaries.

Parameters

event (QGraphicsSceneMouseEvent) – Event

hoverLeaveEvent(event)[source]

Restore original brush when mouse leaves connector button boundaries.

Parameters

event (QGraphicsSceneMouseEvent) – Event

itemChange(change, value)[source]

If this is being removed from the scene while it’s the origin of the link drawer, put the latter to sleep.

class spinetoolbox.project_item_icon.ExecutionIcon(parent)[source]

Bases: PySide6.QtWidgets.QGraphicsEllipseItem

An icon to show information about the item’s execution.

Parameters

parent (ProjectItemIcon) – the parent item

_CHECK = '\uf00c'[source]
_CROSS = '\uf00d'[source]
_CLOCK = '\uf017'[source]
_SKIP = '\uf054'[source]
item_name()[source]
_repaint(text, color)[source]
mark_execution_waiting()[source]
mark_execution_ignored()[source]
mark_execution_started()[source]
mark_execution_finished(item_finish_state)[source]
hoverEnterEvent(event)[source]
hoverLeaveEvent(event)[source]
class spinetoolbox.project_item_icon.ExclamationIcon(parent)[source]

Bases: PySide6.QtWidgets.QGraphicsTextItem

An icon to notify that a ProjectItem is missing some configuration.

Parameters

parent (ProjectItemIcon) – the parent item

FONT_SIZE_PIXELS = 14[source]
clear_notifications()[source]

Clear all notifications.

clear_other_notifications(subtext)[source]

Remove notifications that don’t include the given subtext.

add_notification(text)[source]

Add a notification.

remove_notification(subtext)[source]

Remove the first notification that includes given subtext.

hoverEnterEvent(event)[source]

Shows notifications as tool tip.

Parameters

event (QGraphicsSceneMouseEvent) – Event

hoverLeaveEvent(event)[source]

Hides tool tip.

Parameters

event (QGraphicsSceneMouseEvent) – Event

class spinetoolbox.project_item_icon.RankIcon(parent)[source]

Bases: PySide6.QtWidgets.QGraphicsTextItem

An icon to show the rank of a ProjectItem within its DAG.

Parameters

parent (ProjectItemIcon) – the parent item

_make_path(radius)[source]
update_path(radius)[source]
set_rank(rank)[source]