spinetoolbox.project_item_icon

Classes for drawing graphics items on QGraphicsScene.

authors
  1. Marin (KTH), P. Savolainen (VTT)

date

4.4.2018

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: PySide2.QtWidgets.QGraphicsRectItem

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]
finalize(self, name, x, y)[source]

Names the icon and moves it by given amount.

Parameters
  • name (str) – icon’s name

  • x (int) – horizontal offset

  • y (int) – vertical offset

_setup(self, brush, svg, svg_color)[source]

Setup item’s attributes.

Parameters
  • brush (QBrush) – Used in filling the background rectangle

  • svg (str) – Path to SVG icon file

  • svg_color (QColor) – Color of SVG icon

name(self)[source]

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

Returns

icon’s name

Return type

str

update_name_item(self, new_name)[source]

Set a new text to name item.

Parameters

new_name (str) – icon’s name

set_name_attributes(self)[source]

Set name QGraphicsSimpleTextItem attributes (font, size, position, etc.)

conn_button(self, position='left')[source]

Returns item’s connector button.

Parameters

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

Returns

connector button

Return type

QWidget

Collects outgoing links.

Returns

outgoing links

Return type

list of LinkBase

Collects incoming links.

Returns

outgoing links

Return type

list of LinkBase

run_execution_leave_animation(self, excluded)[source]

Starts the animation associated with execution leaving the icon.

Parameters

excluded (bool) – True if project item was not actually executed.

hoverEnterEvent(self, event)[source]

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

Parameters

event (QGraphicsSceneMouseEvent) – Event

hoverLeaveEvent(self, event)[source]

Disables the drop shadow when mouse leaves icon boundaries.

Parameters

event (QGraphicsSceneMouseEvent) – Event

mousePressEvent(self, event)[source]
mouseMoveEvent(self, event)[source]

Moves icon(s) while the mouse button is pressed. Update links that are connected to selected icons.

Parameters

event (QGraphicsSceneMouseEvent) – Event

moveBy(self, dx, dy)[source]

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

mouseReleaseEvent(self, event)[source]
notify_item_move(self)[source]
contextMenuEvent(self, event)[source]

Show item context menu.

Parameters

event (QGraphicsSceneMouseEvent) – Mouse event

itemChange(self, change, value)[source]

Reacts to item removal and position changes.

In particular, destroys the drop shadow effect when the items 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

select_item(self)[source]

Update GUI to show the details of the selected item.

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

Bases: PySide2.QtWidgets.QGraphicsRectItem

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

Parameters
  • parent (QGraphicsItem) – Project item bg rectangle

  • toolbox (ToolboxUI) – QMainWindow instance

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

brush[source]
hover_brush[source]
property parent(self)[source]
parent_name(self)[source]

Returns project item name owning this connector button.

project_item(self)[source]

Returns the project item this connector button is attached to.

Returns

project item

Return type

ProjectItem

mousePressEvent(self, event)[source]

Connector button mouse press event. Either starts or closes a link.

Parameters

event (QGraphicsSceneMouseEvent) – Event

set_friend_connectors_enabled(self, 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.

mouseDoubleClickEvent(self, event)[source]

Connector button mouse double click event. Makes sure the LinkDrawer is hidden.

Parameters

event (QGraphicsSceneMouseEvent) – Event

hoverEnterEvent(self, event)[source]

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

Parameters

event (QGraphicsSceneMouseEvent) – Event

hoverLeaveEvent(self, event)[source]

Restore original brush when mouse leaves connector button boundaries.

Parameters

event (QGraphicsSceneMouseEvent) – Event

itemChange(self, 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: PySide2.QtWidgets.QGraphicsEllipseItem

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

Parameters

parent (ProjectItemIcon) – the parent item

_CHECK = [source]
_CROSS = [source]
_CLOCK = [source]
_SKIP = [source]
item_name(self)[source]
_repaint(self, text, color)[source]
mark_execution_waiting(self)[source]
mark_execution_started(self)[source]
mark_execution_finished(self, item_finish_state)[source]
hoverEnterEvent(self, event)[source]
hoverLeaveEvent(self, event)[source]
class spinetoolbox.project_item_icon.ExclamationIcon(parent)[source]

Bases: PySide2.QtWidgets.QGraphicsTextItem

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

Parameters

parent (ProjectItemIcon) – the parent item

clear_notifications(self)[source]

Clear all notifications.

add_notification(self, text)[source]

Add a notification.

remove_notification(self, subtext)[source]

Remove the first notification that includes given subtext.

hoverEnterEvent(self, event)[source]

Shows notifications as tool tip.

Parameters

event (QGraphicsSceneMouseEvent) – Event

hoverLeaveEvent(self, event)[source]

Hides tool tip.

Parameters

event (QGraphicsSceneMouseEvent) – Event

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

Bases: PySide2.QtWidgets.QGraphicsTextItem

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

Parameters

parent (ProjectItemIcon) – the parent item

set_rank(self, rank)[source]