class labterm.dashboard_item.DashboardItem(x, y, xgrid: int | None = None, ygrid: int | None = None, channel: int | None = None, data: str | None = None, action: str | None = None, text_before: str = '', text_after: str = '', value: Any | None = None, decimals: int = 2, xycoords: Literal['prop', 'int'] = 'prop', halign: Literal['left', 'center', 'right'] = 'left', valign: Literal['top', 'center', 'bottom'] = 'top', xoffset: int = 0, yoffset: int = 0)[source]#

Bases: ABC

An item drawable on the dashboard, associated with a measured quantity or a state of a specific instrument.

Parameters:
  • x – x position in dashboard. The way this value translates to a column of the terminal is decided by xycoords

  • y – y position in dashboard (higher y corresponds to a lower position). The way this value translates to a row of the terminal is decided by xycoords

  • xgrid (int) – If navigable, determines the x position of the item on the navigable grid

  • ygrid (int) – If navigable, determines the y position of the item on the navigable grid

  • channel (int) – A number associating the items with an instrument. Enter a channel equal to the one set for the desired instrument for the two to communicate.

  • data (str) –

    The specific data associated with the item, obtained by the instrument of corresponding channel. Must be one of the keys of the instrument data dict.

    The item will continuosly update the data in the way described by the instrument update_data() method.

  • action (str) – The action to carry out when selecting the item. Must be one of the actions foreseen by the instrument action() method.

  • text_before (str) – A string to be printed before the main item text

  • text_after (str) – A string to be printed after the main item text

  • value – The main content of the item, contains the value (or data structure) to be printed, updated, or modified as wished.

  • decimals (int) – If displaying floats, determines how many decimals to show.

  • xycoords (Literal["prop", "int"]) – Determines how to translate the x,y values into terminal screen coordinates: prop: coordinate system of the axes, x,y are floats between 0 and 1, (0, 0) is top left, and (1, 1) is top right. int: exact column and row position, x,y, are ints.

  • halign (Literal["left", "center", "right"]) – horizontal alignment of the item with respect to the x,y coordinates

  • valign (Literal["top", "center", "bottom"]) – vertical alignment of the item with respect to the x,y coordinates

  • xoffset (int) – number of columns, horizontal offset with respect to the x position. Useful to group together groups of items.

  • yoffset (int) – number of rows, vertical offset with respect to the y position. Useful to group together groups of items.

abstractmethod draw(screen: window, selected: bool = False) None[source]#

Draw the item on the screen

editable: bool = False#
enter_edit()[source]#

This method is called when an item enters editing mode.

exit_edit()[source]#

This method is called when an item enters editing mode.

handle_edit_key(key) tuple[bool, float | None][source]#

Determines what happens when a key is pressed while editing an item.

Returns:

A tuple (exit_editing, commit_value). If exit_editing=True the dashboard will get out of editing mode, and the item action will be called with the commit_value returned. If commit_value=None the dahsboard will cancel the edit.

Return type:

tuple[bool, Optional[float]]

navigable: bool = False#
class labterm.dashboard_item.Editable(x, y, xgrid: int, ygrid: int, channel: int, data: str, action: str, initial_value=0.0, **kwargs)[source]#

Bases: DashboardItem

A dynamic, navigable, editable item, which sets, updates and prints data associated with an instrument.

Parameters:
  • x – x position in dashboard. The way this value translates to a column of the terminal is decided by xycoords

  • y – y position in dashboard (higher y corresponds to a lower position). The way this value translates to a row of the terminal is decided by xycoords

  • xgrid (int) – If navigable, determines the x position of the item on the navigable grid

  • ygrid (int) – If navigable, determines the y position of the item on the navigable grid

  • channel (int) –

    A number associating the items with an instrument.

    Enter a channel equal to the one set for the desired instrument for the two to communicate.

  • data (str) –

    The specific data associated with the item, obtained by the instrument of corresponding channel. Must be one of the keys of the instrument data dict.

    The item will continuosly update the data in the way described by the instrument update_data() method.

  • action (str) –

    The action to carry out when selecting the item.

    Must be one of the actions foreseen by the instrument action() method.

  • initial_value (bool) – The initial value stored in the item.

  • **kwargs – See DashboardItem for the full list of accepted arguments.

draw(screen: window, selected: bool)[source]#

Draw the item on the screen

editable: bool = True#
enter_edit()[source]#

This method is called when an item enters editing mode.

exit_edit()[source]#

This method is called when an item enters editing mode.

handle_edit_key(key) tuple[bool, float | None][source]#

Determines what happens when a key is pressed while editing an item.

Returns:

A tuple (exit_editing, commit_value). If exit_editing=True the dashboard will get out of editing mode, and the item action will be called with the commit_value returned. If commit_value=None the dahsboard will cancel the edit.

Return type:

tuple[bool, Optional[float]]

navigable: bool = True#
class labterm.dashboard_item.Label(x, y, text: str, **kwargs)[source]#

Bases: DashboardItem

A static, non-navigable and non-editable item, without associated data or action.

Parameters:
  • x – x position in dashboard. The way this value translates to a column of the terminal is decided by xycoords

  • y – y position in dashboard (higher y corresponds to a lower position). The way this value translates to a row of the terminal is decided by xycoords

  • text (str) – The text to be printed

  • **kwargs – See DashboardItem for the full list of accepted arguments.

draw(screen: window, **kwargs)[source]#

Draw the item on the screen

class labterm.dashboard_item.Light(x, y, channel: int, data: str, initial_value=False, **kwargs)[source]#

Bases: DashboardItem

A dynamic, non-navigable, non-editable item, which updates boolean data associated with an instrument and represents it with a green (True) or red (False) circle in a single character.

Parameters:
  • x – x position in dashboard. The way this value translates to a column of the terminal is decided by xycoords

  • y – y position in dashboard (higher y corresponds to a lower position). The way this value translates to a row of the terminal is decided by xycoords

  • xgrid (int) – If navigable, determines the x position of the item on the navigable grid

  • ygrid (int) – If navigable, determines the y position of the item on the navigable grid

  • channel (int) –

    A number associating the items with an instrument.

    Enter a channel equal to the one set for the desired instrument for the two to communicate.

  • data (str) –

    The specific data associated with the item, obtained by the instrument of corresponding channel. Must be one of the keys of the instrument data dict.

    The item will continuosly update the data in the way described by the instrument update_data() method.

  • initial_value (bool) – The initial value stored in the item.

  • **kwargs – See DashboardItem for the full list of accepted arguments.

draw(screen: window, **kwargs)[source]#

Draw the item on the screen

class labterm.dashboard_item.Readonly(x, y, channel: int, data: str, initial_value=0.0, **kwargs)[source]#

Bases: DashboardItem

A dynamic, non-navigable, non-editable item, which updates and prints data associated with an instrument.

Parameters:
  • x – x position in dashboard. The way this value translates to a column of the terminal is decided by xycoords

  • y – y position in dashboard (higher y corresponds to a lower position). The way this value translates to a row of the terminal is decided by xycoords

  • xgrid (int) – If navigable, determines the x position of the item on the navigable grid

  • ygrid (int) – If navigable, determines the y position of the item on the navigable grid

  • channel (int) –

    A number associating the items with an instrument.

    Enter a channel equal to the one set for the desired instrument for the two to communicate.

  • data (str) –

    The specific data associated with the item, obtained by the instrument of corresponding channel. Must be one of the keys of the instrument data dict.

    The item will continuosly update the data in the way described by the instrument update_data() method.

  • initial_value (bool) – The initial value stored in the item.

  • **kwargs – See DashboardItem for the full list of accepted arguments.

draw(screen: window, **kwargs)[source]#

Draw the item on the screen

class labterm.dashboard_item.Switch(x, y, xgrid: int, ygrid: int, channel: int, data: str, action: str, initial_value: bool = False, text: tuple[str, str] = ('ON', 'OFF'), **kwargs)[source]#

Bases: DashboardItem

A dynamic, navigable, non-editable item, which alternates between two possible states.

Parameters:
  • x – x position in dashboard. The way this value translates to a column of the terminal is decided by xycoords

  • y – y position in dashboard (higher y corresponds to a lower position). The way this value translates to a row of the terminal is decided by xycoords

  • xgrid (int) – If navigable, determines the x position of the item on the navigable grid

  • ygrid (int) – If navigable, determines the y position of the item on the navigable grid

  • channel (int) – A number associating the items with an instrument. Enter a channel equal to the one set for the desired instrument for the two to communicate.

  • data (str) –

    The specific data associated with the item, obtained by the instrument of corresponding channel. Must be one of the keys of the instrument data dict. Must be of boolean nature.

    The item will continuosly update the data in the way described by the instrument update_data() method.

  • action (str) –

    The action to carry out when the item switches between the two possible states.

    Must be one of the actions foreseen by the instrument action() method.

  • initial_value (bool) – The initial value stored in the item.

  • **kwargs – See DashboardItem for the full list of accepted arguments.

draw(screen: window, selected)[source]#

Draw the item on the screen

editable: bool = False#
navigable: bool = True#