8.5.6.8. pymodaq_gui.utils.utils module

pymodaq_gui.utils.utils.clickable(widget)[source]
pymodaq_gui.utils.utils.create_nested_menu(layers, items_per_layer, pattern='Menu', prefix_pattern='Sub', use_index_tracking=False)[source]

Creates a nested dictionary structure with specified layers and items per layer.

Parameters:
  • layers (int) – Number of layers in the nested structure

  • items_per_layer (int or list) – Number of items per layer. Can be an integer (same for all layers) or a list (specific count for each layer)

  • pattern (str) – Base pattern for naming items (default: “Menu”)

  • prefix_pattern (str) – Prefix pattern for sub-levels (default: “Sub”)

  • use_index_tracking (bool) – If True, adds _ijk tracking to names (default: False)

Returns:

Nested dictionary structure

Return type:

dict

Examples

create_nested_menu(3, 2, use_index_tracking=True) creates: {

‘Menu_1’: {

‘SubMenu_11’: [‘SubSubMenu_111’, ‘SubSubMenu_112’], ‘SubMenu_12’: [‘SubSubMenu_121’, ‘SubSubMenu_122’]

}, ‘Menu_2’: {

‘SubMenu_21’: [‘SubSubMenu_211’, ‘SubSubMenu_212’], ‘SubMenu_22’: [‘SubSubMenu_221’, ‘SubSubMenu_222’]

}

}

pymodaq_gui.utils.utils.exec()[source]
pymodaq_gui.utils.utils.first_available_integer(liste)[source]
pymodaq_gui.utils.utils.h5tree_to_QTree(base_node, base_tree_elt=None, pixmap_items=[])[source]
Convert a loaded h5 file to a QTreeWidgetItem element structure containing two columns.
The first is the name of the h5 current node, the second is the path of the node in the h5 structure.

Recursive function discreasing on base_node.

Parameters

Type

Description

h5file

instance class File from tables module

loaded h5 file

base_node

pytables h5 node

parent node

base_tree_elt

QTreeWidgetItem

parent QTreeWidgetItem element

Returns:

h5 structure copy converted into QtreeWidgetItem structure.

Return type:

QTreeWidgetItem

See also

h5tree_to_QTree

pymodaq_gui.utils.utils.mkQApp(name)[source]
pymodaq_gui.utils.utils.pngbinary2Qlabel(databinary, scale_height=None)[source]
pymodaq_gui.utils.utils.set_dark_palette(app)[source]
pymodaq_gui.utils.utils.set_enable_recursive(children, enable=False)[source]

Apply the enable state on all children widgets, do it recursively

Parameters:
  • children ((list) elements children ofa pyqt5 element)

  • enable ((bool) set enabled state (True) of all children widgets)

pymodaq_gui.utils.utils.start_qapplication()[source]
Return type:

QApplication

pymodaq_gui.utils.utils.widget_to_png_to_bytes(widget, keep_aspect=True, width=200, height=100)[source]

Renders the widget content in a png format as a bytes string :type widget: (QWidget) the widget to render :param widget: :type widget: (QWidget) the widget to render :type keep_aspect: (bool) if True use width and the widget aspect ratio to calculate the height :param keep_aspect: if False use set values of width and height to produce the png :type keep_aspect: (bool) if True use width and the widget aspect ratio to calculate the height :type width: (int) the rendered width of the png :param width: :type width: (int) the rendered width of the png :type height: (int) the rendered width of the png :param height: :type height: (int) the rendered width of the png

Return type:

binary string