8.5.6.8. pymodaq_gui.utils.utils module
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:
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.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
- pymodaq_gui.utils.utils.set_enable_recursive(children, enable=False)[source]
Apply the enable state on all children widgets, do it recursively
- 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 :param widget: :type widget: (QWidget) the widget to render :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 :param width: :type width: (int) the rendered width of the png :param height: :type height: (int) the rendered width of the png
- Return type:
binary string