pylab_ml.gui.instruments.minisct.minisct.Gui

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

Bases: Gui

MiniSCT Gui.

Inherited from base_instrument

status

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

Initialize the GUI for the MiniSCT instrument.

Parameters:
  • parent (object) – The parent widget for this GUI.

  • name (str, optional) – The name of the instrument. Default is “miniSCT”.

  • parentwindow (object, optional) – The parent window for this GUI. Default is None.

  • channel (int, optional) – The channel number. Default is None.

Methods

__init__(parent[, name, parentwindow, channel])

Initialize the GUI for the MiniSCT 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 close event for the GUI by publishing an 'off' command and then calling the base class's close method.

dprint(msg)

Print a debug message if debugging is enabled.

filtersubtopic(value)

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

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.

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)

Common MQTT receive messages, get raw MQTT data for more information.

myadjustUI()

Adjust the GUI elements for the MiniSCT instrument.

objectName2mqttName(name)

Filter from the object name the right MQTT name.

publish(cmd[, value, instName])

Publish a command and value over MQTT.

retranslateUi(Form)

Retranslate the UI, set the text of the widgets.

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.

svg2mqtt(name, value)

Overwrite from the base_instrument.svg2mqtt.

unitOfMeasurement(value[, unit])

Convert a value with a unit to its numerical representation.

Attributes

channel

Get the channel number.

id

Return the id of the instrument, which is used for MQTT topics.

mqtt_cmds

mqtt_status

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

status

Return the current status message from the status bar.

subtopic

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

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.

property channel

Get the channel number.

close(event=None)[source]

Handle the close event for the GUI by publishing an ‘off’ command and then calling the base class’s close method.

dprint(msg)[source]

Print a debug message if debugging is enabled.

filtersubtopic(value)[source]

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

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

Return the id of the instrument, which is used for MQTT topics.

isVisible()[source]

Return whether the GUI is currently visible.

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]

Common MQTT receive messages, get raw MQTT data for more information.

Parameters:
  • instName (str) – The name of the instrument instance.

  • msg (dict) – The MQTT message received.

myadjustUI()[source]

Adjust the GUI elements for the MiniSCT 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.

retranslateUi(Form)[source]

Retranslate the UI, set the text of the widgets.

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.

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]

Overwrite from the base_instrument.svg2mqtt. Translate svg-names to his mqtt command.

Parameters:
  • name (str) – The name of the SVG element that triggered the event.

  • value (any) – The value associated with the event, which may be used to determine the MQTT command to publish.

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