pylab_ml.gui.instruments.matrix.matrix.Gui

class Gui(parent=None, name='matrix', parentwindow=None)[source]

Bases: Gui

Gui class for the matrix instrument.

__init__(parent=None, name='matrix', parentwindow=None)[source]

Initialize the GUI for the matrix instrument.

Parameters:
  • parent (QWidget, optional) – The parent widget of the GUI.

  • name (str, optional) – The name of the instrument.

  • parentwindow (QWidget, optional) – The parent window of the GUI.

Methods

__init__([parent, name, parentwindow])

Initialize the GUI for the matrix instrument.

add_menue(menue, connect, enabled[, ...])

Add a menue item to Setup

add_menuicon(typ[, connect])

Add icon and action to the menu.

adjustUI()

Adjust the UI, set the title and icons and connect the quit action.

close([event])

Handle the closing of the GUI by closing the matrix window and the main GUI window if necessary.

color_inaktiv(color)

Calculate the inactive color based on the given color and the COLOR_INAKTIV factor.

create_CBox(index)

Create a combo box and its associated label for the given index.

create_label(form, x, y[, text])

Create a label at the given x and y coordinates with the specified text.

create_line(form, x, y)

Create a line (horizontal or vertical) in the given form.

create_net(form, x, y)

Create a radio button representing a net at the given x and y coordinates.

discardTable()

Handle the discarding of the table by resetting the instance name extension, MQTT status, and deleting all combo boxes.

dprint(msg)

Print a debug message if debugging is enabled.

edit()

Handle the editing of the matrix by enabling the tab edit and allowing the user to modify the connection and constants tables.

edit_label(event[, source_object])

Handle the mouse press event on a label to allow editing of the label's text.

editfinish_label()

Handle the completion of label editing by updating the label's text and hiding the line edit.

filtersubtopic(value)

Filter the subtopic from the value, if the value starts with the topinstname.

get_nets(categorie, scenario)

Get the nets for a given category and scenario from the connection table.

gui2mqtt(widget)

Function connect a Gui-widget to mqtt, it sends a mqtt set command with the value from the Gui-widget.

gui_disconnect()

Disconnect the GUI, set the MQTT status to "disconnect" and disable the frame.

hide()

Hide the GUI.

isVisible()

Return whether the GUI is currently visible.

load_connectionTable()

Handle the loading of the connection table by publishing the corresponding command to retrieve the connection table data.

mqttConnectSVGWidget(filename, name[, channel])

Create an InteractiveSvgWidget and load the filname.

mqttConnectWidgets()

Connect all object which start with MQTT_ to the function gui2mqtt().

mqttreceive(instName, msg)

Handle incoming MQTT messages and update the GUI elements accordingly.

myadjustUI()

Adjust the GUI elements for the matrix instrument.

objectName2mqttName(name)

Filter from the object name the right MQTT name.

publish(cmd[, value, instName])

Publish a command and value over MQTT.

reset()

Reset the GUI to its initial state by clearing the matrix array and resetting the combo boxes.

retranslateUi(Form)

Set the text for the GUI elements based on the current language settings.

setLabel(Label, value[, ext])

Set the text of a label.

set_Geometry(geometry)

Set the geometry of the GUI, check if the geometry is on the actual screen.

show()

Show the GUI.

show_matrix()

Show the matrix window with the current connection and constants tables.

svg2mqtt(name, value)

Publish the name and value over mqtt.

unitOfMeasurement(value[, unit])

Convert a value with a unit to its numerical representation.

update_CBox(index, name, color)

Update the combo box and its associated label for the given index, name, and color.

update_mainwindow()

Update the main window of the GUI based on the current connection table and constants table.

update_matrixarray()

Update the matrix array based on the current connection table and constants table.

update_matrixcolor()

Update the colors of the matrix labels based on the current connection table and constants table.

Attributes

CB_OFFSET_X

CB_OFFSET_Y

CB_SPACE_X

CB_SPACE_Y

CB_WIDTH

COLOR_INAKTIV

Fontsize

RADIOBUTTONWIDTH

SetCrosspointState

Get the current crosspoint state.

X_LABELHIGH

X_LLABELWIDTH

X_OFFSET

X_RLABELWIDTH

X_STEP

Y_BLABELHIGH

Y_OFFSET

Y_STEP

Y_TLABELHIGH

Y_TLABELWIDTH

clear

dic_connectionTable

Get the connection table dictionary.

dic_constantsTable

Get the constants table dictionary.

disconnect

id

Get the ID of the instrument.

mqtt_status

Return the MQTT status of the instrument, which is either "connect" or "disconnect".

set

status

Return the current status message from the status bar.

subtopic

Return the subtopic of the instrument, which is the part after the topinstname.

property SetCrosspointState

Get the current crosspoint state.

add_menue(menue, connect, enabled, checkable=False, checked=False)[source]

Add a menue item to Setup

Parameters:
  • menue (string) – The text of the menu item.

  • connect (function) – The function to be called when the menu item is triggered.

  • enabled (bool) – Whether the menu item is enabled.

  • checkable (bool, optional) – Whether the menu item is checkable. The default is False.

  • checked (bool, optional) – Whether the menu item is checked. The default is False.

add_menuicon(typ, connect=None)[source]

Add icon and action to the menu.

Parameters:
  • typ (string) – The type of the menu item.

  • connect (function, optional) – The function to be called when the menu item is triggered. The default is None.W

“onoff” : on/off

adjustUI()[source]

Adjust the UI, set the title and icons and connect the quit action.

close(event=None)[source]

Handle the closing of the GUI by closing the matrix window and the main GUI window if necessary.

color_inaktiv(color)[source]

Calculate the inactive color based on the given color and the COLOR_INAKTIV factor.

Parameters:

color (tuple) – The RGB color to be modified.

Returns:

result – The inactive RGB color.

Return type:

tuple

create_CBox(index)[source]

Create a combo box and its associated label for the given index.

Parameters:

index (int) – The index of the combo box to create.

create_label(form, x, y, text=None)[source]
Create a label at the given x and y coordinates with the specified text.

x== -1 -> place wire numbers left x== -2 -> place wire text right y== -1 -> pace wire number at top vertical y== -2 -> pace wire text at bottom vertical

Parameters:
  • form (QWidget) – The parent widget for the label.

  • x (int) –

    The x-coordinate for the label. Special values:

    -1: place wire numbers on the left -2: place wire text on the right

  • y (int) –

    The y-coordinate for the label. Special values:

    -1: place wire numbers at the top -2: place wire text at the bottom

  • text (str, optional) – The text to display on the label. If None, default text will be used based on the coordinates.

Returns:

label – The created label with the specified properties.

Return type:

QLabel

create_line(form, x, y)[source]

Create a line (horizontal or vertical) in the given form.

Parameters:
  • form (QWidget) – The parent widget in which the line will be created.

  • x (int) – The x-coordinate or special value indicating a horizontal line (-1).

  • y (int) – The y-coordinate or special value indicating a vertical line (-1).

Returns:

line – The created line (either horizontal or vertical) with the specified properties.

Return type:

QFrame

create_net(form, x, y)[source]

Create a radio button representing a net at the given x and y coordinates.

Parameters:
  • form (QWidget) – The parent widget for the radio button.

  • x (int) – The x-coordinate of the net.

  • y (int) – The y-coordinate of the net.

Returns:

radioButton – The created radio button representing the net.

Return type:

QRadioButton

property dic_connectionTable

Get the connection table dictionary.

property dic_constantsTable

Get the constants table dictionary.

discardTable()[source]

Handle the discarding of the table by resetting the instance name extension, MQTT status, and deleting all combo boxes.

dprint(msg)[source]

Print a debug message if debugging is enabled.

edit()[source]

Handle the editing of the matrix by enabling the tab edit and allowing the user to modify the connection and constants tables.

edit_label(event, source_object=None)[source]

Handle the mouse press event on a label to allow editing of the label’s text.

Parameters:
  • event (QMouseEvent) – The mouse event that triggered the label editing.

  • source_object (QLabel, optional) – The label that was clicked, triggering the edit. If None, the event’s source will be used.

editfinish_label()[source]

Handle the completion of label editing by updating the label’s text and hiding the line edit.

filtersubtopic(value)[source]

Filter the subtopic from the value, if the value starts with the topinstname.

get_nets(categorie, scenario)[source]

Get the nets for a given category and scenario from the connection table.

Parameters:
  • categorie (str) – The category of the nets.

  • scenario (str) – The scenario of the nets.

Returns:

  • color (tuple) – The RGB color associated with the category.

  • result (list) – A list of nets, where each net is represented as a list of three integers [x1, x2, y].

gui2mqtt(widget)[source]

Function connect a Gui-widget to mqtt, it sends a mqtt set command with the value from the Gui-widget.

Parameters:

widget (QtWidgets.QWidget) – The GUI widget that triggered the MQTT command, expected to have an objectName that follows the

Return type:

None.

gui_disconnect()[source]

Disconnect the GUI, set the MQTT status to “disconnect” and disable the frame.

hide()[source]

Hide the GUI.

property id

Get the ID of the instrument.

isVisible()[source]

Return whether the GUI is currently visible.

load_connectionTable()[source]

Handle the loading of the connection table by publishing the corresponding command to retrieve the connection table data.

mqttConnectSVGWidget(filename, name, channel=None)[source]

Create an InteractiveSvgWidget and load the filname. Connect all clicks to the text id’s to the function svg2mqtt().

Parameters:
  • filename (string) – The path to the SVG file to be loaded into the widget.

  • name (string) – The base name for the widget, used for MQTT topic construction.

  • channel (string, optional) – An optional channel identifier to be appended to the name for MQTT topic construction. The default is None.

Returns:

svgWidget – The created InteractiveSvgWidget with the loaded SVG file and connected signals.

Return type:

InteractiveSvgWidget

mqttConnectWidgets()[source]

Connect all object which start with MQTT_ to the function gui2mqtt().

Create a list with all commands in self.mqtt_cmds

property mqtt_status

Return the MQTT status of the instrument, which is either “connect” or “disconnect”.

mqttreceive(instName, msg)[source]

Handle incoming MQTT messages and update the GUI elements accordingly.

Parameters:
  • instName (str) – The name of the instance sending the MQTT message.

  • msg (dict) – The MQTT message containing the command and payload.

myadjustUI()[source]

Adjust the GUI elements for the matrix instrument.

objectName2mqttName(name)[source]

Filter from the object name the right MQTT name.

eg. objectname = MQTT_voltage -> Voltage listen on get and set

= MQTT_set_I_limit -> I_limit listen only on set = MQTT_get_I_limit -> I_limit listen only on get = TAB_ch -> Name for a tab-name

Parameters:

name (string) – The object name to be filtered.

Returns:

  • listen (string) – The type of MQTT command to listen for (“set”, “get”, or “”).

  • result (string) – The filtered MQTT name extracted from the object name.

publish(cmd, value='', instName=None)[source]

Publish a command and value over MQTT.

Parameters:
  • cmd (string) – The command to be published.

  • value (string, optional) – The value associated with the command. The default is an empty string.

  • instName (string, optional) – The name of the instrument. If None, the instance’s name is used. The default is None.

reset()[source]

Reset the GUI to its initial state by clearing the matrix array and resetting the combo boxes.

retranslateUi(Form)[source]

Set the text for the GUI elements based on the current language settings.

setLabel(Label, value, ext=None)[source]

Set the text of a label.

Parameters:
  • Label (object) – the label object.

  • value (string) – this text will be displayed.

  • ext (string, optional) – extention, The default is None.

Return type:

None.

set_Geometry(geometry)[source]

Set the geometry of the GUI, check if the geometry is on the actual screen.

Parameters:

geometry (tuple) – A tuple of the form (x, y, width, height) representing the geometry of the GUI.

show()[source]

Show the GUI.

show_matrix()[source]

Show the matrix window with the current connection and constants tables.

property status

Return the current status message from the status bar.

property subtopic

Return the subtopic of the instrument, which is the part after the topinstname.

svg2mqtt(name, value)[source]

Publish the name and value over mqtt. Overwrite this function if you need a more complex form.

Parameters:
  • name (string) – The name of the SVG element that was changed.

  • value (string) – The new value of the SVG element.

unitOfMeasurement(value, unit=None)[source]

Convert a value with a unit to its numerical representation.

Parameters:
  • value (string) – The value with a unit (e.g., “10 k”).

  • unit (string, optional) – The unit to use for conversion. If None, the unit is inferred from the value.

Returns:

The numerical representation of the value.

Return type:

float

update_CBox(index, name, color)[source]

Update the combo box and its associated label for the given index, name, and color.

Parameters:
  • index (int) – The index of the combo box to update.

  • name (str) – The name to set for the combo box and its label.

  • color (tuple) – The RGB color to set for the combo box and its label.

update_mainwindow()[source]

Update the main window of the GUI based on the current connection table and constants table.

update_matrixarray()[source]

Update the matrix array based on the current connection table and constants table.

update_matrixcolor()[source]

Update the colors of the matrix labels based on the current connection table and constants table.