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 structureitems_per_layer (
intorlist) – 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:
See also
- 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)ofall children widgets)
- 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 widgettorender:param widget: :type widget:(QWidget) the widgettorender:type keep_aspect:(bool) if True use widthandthe widget aspect ratiotocalculate 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 widthandthe widget aspect ratiotocalculate the height:type width:(int) the rendered widthofthe png:param width: :type width:(int) the rendered widthofthe png:type height:(int) the rendered widthofthe png:param height: :type height:(int) the rendered widthofthe png- Return type:
binary string