Skip to content

polychron.views.ManageGroupRelationshipsView Module

GroupBoxPalette

A sequence of colours used as a palette for the group boxes

__init__

__init__(palette: Literal['pastel', 'tab20', 'cubehelix'] = 'pastel')

Initialise the colour palette using a sequence from matplotlib, with some re-ordering so sequential elements are not matched

__len__

__len__() -> int

Get the number of colours in the palette

Returns:

Type Description
int

The number of colours in the palette

__getitem__

__getitem__(idx: int) -> tuple[str, str]

Get the pair of colours from the index, containing the background colour, and the contrasting label colour

Parameters:

Name Type Description Default
idx int

the index / key of the item to access

required

Returns:

Type Description
tuple[str, str]

The pair of colours at the specified index in hex codes

__contrasting_color classmethod

__contrasting_color(rgb: tuple[float, float, float]) -> tuple[float, float, float]

Given an rgb-tuple of floats in the range [0,1], return the colour with the most contrast from the list of available text colours.

Ideally a contrast ratio threshold of 4.5:1 or 3:1 would also be required following accessibility guidelines, but that is not possible for all colour palettes in distributed with matplotlib

Parameters:

Name Type Description Default
rgb tuple[float, float, float]

a 3-tuple of normalised colour channels

required

Returns:

Type Description
tuple[float, float, float]

a 3-tuple of normalised colour channels with sufficient contrast to the base colour

ManageGroupRelationshipsView

Bases: PopupView

View for managing group relationships

Formerly part of popupWindow3, Part of the Rendering chronological graph process

group_label_dict instance-attribute

group_label_dict = {}

Dictionary of group boxes/tkinter label elements

__group_box_mouse_press_callback instance-attribute

__group_box_mouse_press_callback: Callable[[], Any] = lambda event: None

Callback method for mouse press events on group box

__group_box_mouse_move_callback instance-attribute

__group_box_mouse_move_callback: Callable[[], Any] = lambda event: None

Callback method for mouse move events on group box

__group_box_mouse_release_callback instance-attribute

__group_box_mouse_release_callback: Callable[[], Any] = lambda event: None

Callback method for mouse release events on group box

__group_box_mouse_cursor instance-attribute

__group_box_mouse_cursor = ''

The mouse cursor to display on group boxes when they are movable

__confirm_callback instance-attribute

__confirm_callback: Callable[[], Any] = lambda: None

Callback method for when the confirm button is pressed.

Stored in the view to allow deletion and recreation of the confirm button.

__render_callback instance-attribute

__render_callback: Callable[[], Any] = lambda: None

Callback method for when the render button is pressed.

Stored in the view to allow deletion and recreation of the render button.

__change_callback instance-attribute

__change_callback: Callable[[], Any] = lambda: None

Callback method for when the change button is pressed.

Stored in the view to allow deletion and recreation of the change button.

COLOURS instance-attribute

COLOURS = GroupBoxPalette()

A palette of colours and corresponding text colours for the boxes used for groups. If more colours are required than available the palette will wrap

__init__

__init__(parent: Frame) -> None

Construct the view, without binding any callbacks

get_group_canvas_dimensions

get_group_canvas_dimensions() -> tuple[int, int]

Get the dimensions of the group canvas, so the presenter can compute initial box placement based on known relationships

Returns:

Type Description
tuple[int, int]

A tuple (width, height) containing the dimensions of the canvas area.

create_group_boxes

create_group_boxes(group_boxes_xywh: dict[str, tuple[float, float, float, float]]) -> None

Create a box within the canvas for each group label, with an initial location provided by the presenter.

Colours will be selected from a palette.

Parameters:

Name Type Description Default
group_boxes_xywh dict[str, tuple[float, float, float, float]]

an (ordered) dictionary of boxes (x, y, w, h) to create from the presenter

required

get_group_box_properties

get_group_box_properties() -> dict[str, tuple[float, float, float, float]]

Get a dictionary containing the (x, y, w, h) for each group box

Returns:

Type Description
dict[str, tuple[float, float, float, float]]

A dictionary indexed by the group label with the (x, y, w, h) for each box.

update_box_coords

update_box_coords(boxes: dict[str, tuple[float, float]])

Update the coordinates and size for each group box

Parameters:

Name Type Description Default
boxes dict[str, tuple[float, float]]

A dictionary indexed by the group label with the (x, y) for each box.

required

update_canvas

update_canvas() -> None

Update the canvas to ensure coordinates are correct?

draw_arrow

draw_arrow() -> None

draw the x-axis arrow / label on the white canvas

update_relationships_table

update_relationships_table(relationships_dict: dict[tuple[str, str], str | None]) -> None

Update the table of group relationships.

This is the 3 column version, for the confirmation step in the residual checking process.

Formerly part of popupwindow3.get_coords

Parameters:

Name Type Description Default
relationship_dict

A dictionary of relationship types for each directed group relationship

required

bind_group_box_mouse_events

bind_group_box_mouse_events(on_press: Callable[[], Any] | None, on_move: Callable[[], Any] | None, on_release: Callable[[], Any] | None, cursor: Literal['', 'fleur'] | None) -> None

Bind the callback for mouse events to move group boxes.

This is set on a (private) view class members, to avoid having to call this method again if the group boxes are ever re-generated.

Parameters:

Name Type Description Default
on_press Callable[[], Any] | None

Callback function for mouse press events on the group box labels

required
on_move Callable[[], Any] | None

Callback function for mouse move events on the group box labels

required
on_release Callable[[], Any] | None

Callback function for mouse release events on the group box labels

required
cursor Literal['', 'fleur'] | None

The tkinter cursor string to use when the mouse is over the group box labels. Use 'fluer' when the boxes can be dragged.

required

bind_confirm_button

bind_confirm_button(callback: Callable[[], Any]) -> None

Bind the callback for when the confirm_button is pressed

bind_render_button

bind_render_button(callback: Callable[[], Any]) -> None

Bind the callback for when the render_button is pressed

bind_change_button

bind_change_button(callback: Callable[[], Any]) -> None

Bind the callback for when the change_button is pressed

layout_step_two

layout_step_two() -> None

Update the view to show the UI for when after the confirm button has been pressed.

This updates updates some text and changes which buttons are visible

Formerly part of popupWindow3.get_coords

layout_step_one

layout_step_one() -> None

Update the view to show the pre-confirmation state

This updates updates some text and changes which buttons are visible

Formerly popupWindow3.back_func