pylablib.core.gui.widgets package

Submodules

pylablib.core.gui.widgets.button module

class pylablib.core.gui.widgets.button.ToggleButton(parent=None)[source]

Bases: object

Expanded toggle button.

Maintains internally stored consistent value (which can be, e.g., accessed from different threads). Allows setting different captions of pressed/unpressed, and uses those to represent values.

set_value_labels(labels)[source]

Set a list of values corresponding to combo box indices.

Can be either a list of values, whose length must be equal to the number of options, or None (don’t change the button label on toggle).

value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>

Signal emitted when value is changed

get_value()[source]

Get current value

set_value(value, notify_value_change=True)[source]

Set current value.

If notify_value_change==True, emit the value_changed signal; otherwise, change value silently.

repr_value(value)[source]

Return representation of value as a caption text

pylablib.core.gui.widgets.combo_box module

class pylablib.core.gui.widgets.combo_box.ComboBox(parent)[source]

Bases: object

Expanded combo box.

Maintains internally stored consistent value (which can be, e.g., accessed from different threads). Allows setting values which are reported via value_changed signal instead of simple indices.

wheelEvent(event)[source]
set_out_of_range(action='error')[source]

Set behavior when out-of-range value is applied.

Can be "error" (raise error), "reset" (reset to no-value position), "reset_start" (reset to the first position) or "ignore" (keep current value).

set_direct_index_action(action='error')[source]

Set behavior when index values are specified, but direct indexing is used.

Can be "ignore" (do not allow direct indexing and treat any value as index value), "value_default" (allow direct indexing, but prioritize index values with the same value), or "index_default" (allow direct indexing and prioritize it if index value with the same value exists).

index_to_value(idx)[source]

Turn numerical index into value

value_to_index(value)[source]

Turn value into a numerical index

set_index_values(index_values, value=None, index=None)[source]

Set a list of values corresponding to combo box indices.

Can be either a list of values, whose length must be equal to the number of options, or None (simply use indices). Note: if the number of combo box options changed (e.g., using addItem or insertItem methods), the index values need to be manually updated; otherwise, the errors might arise if the index is larger than the number of values. If value is specified, set as the new values. If index is specified, use it as the index of a new value; if both value and index are specified, the value takes priority.

get_index_values()[source]

Return the list of values corresponding to combo box indices

get_options()[source]

Return the list of labels corresponding to combo box indices

get_options_dict()[source]

Return the dictionary {value: label} of the option labels

set_options(options, index_values=None, value=None, index=None)[source]

Set new set of options.

If index_values is not None, set these as the new index values; otherwise, index values are reset. If options is a dictionary, interpret it as a mapping {option: index_value}. If value is specified, set as the new values. If index is specified, use it as the index of a new value; if both value and index are specified, the value takes priority.

insert_option(option, index_value=None, index=None)[source]

Insert or append a new option to the list

Insertion (i.e., index is not None) only works for index-valued combo boxes.

value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>

Signal emitted when value is changed

get_value()[source]

Get current numerical value

set_value(value, notify_value_change=True)[source]

Set current value.

If notify_value_change==True, emit the value_changed signal; otherwise, change value silently.

repr_value(value)[source]

Return representation of value as a combo box text

pylablib.core.gui.widgets.container module

class pylablib.core.gui.widgets.container.TTimer(name, period, timer)

Bases: tuple

name
period
timer
class pylablib.core.gui.widgets.container.TTimerEvent(start, loop, stop, timer)

Bases: tuple

loop
start
stop
timer
class pylablib.core.gui.widgets.container.TChild(name, widget, gui_values_path)

Bases: tuple

gui_values_path
name
widget
class pylablib.core.gui.widgets.container.IQContainer(*args, name=None, **kwargs)[source]

Bases: object

Basic controller object which combines and controls several other widget.

Can either corresponds to a widget (e.g., a frame or a group box), or simply be an organizing entity.

Parameters:

name – entity name (used by default when adding this object to a values table)

Abstract mix-in class, which needs to be added to a class inheriting from QObject. Alternatively, one can directly use QContainer, which already inherits from QObject.

TimerUIDGenerator = <pylablib.core.utils.general.NamedUIDGenerator object>
contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
setup_name(name)[source]

Set the object’s name

setup(name=None)[source]

Setup the container by initializing its GUI values and setting the ctl attribute

add_timer(name, period, autostart=True)[source]

Add a periodic timer with the given name and period.

Rarely needs to be called explicitly (one is created automatically if timer event is created). If autostart==True and the container has been started (by calling start() method), start the timer as well.

start_timer(name)[source]

Start the timer with the given name (also called automatically on start() method)

stop_timer(name)[source]

Stop the timer with the given name (also called automatically on stop() method)

is_timer_running(name)[source]

Check if the timer with the given name is running

add_timer_event(name, loop=None, start=None, stop=None, period=None, timer=None, autostart=True)[source]

Add timer event with the given name.

Add an event which should be called periodically (e.g., a GUI update). Internally implemented through Qt timers. loop, start and stop are the functions called, correspondingly, on timer (periodically), when timer is start, and when it’s finished. One can either specify the timer by name (timer parameter), or create a new one with the given period. If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_child_values(name, widget, path, add_change_event=True)[source]

Add child’s values to the container’s table.

If widget is a container and path=="" or ends in "/*" (e.g., "subpath/*"), use its setup_gui_values to make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_child(name, widget, gui_values_path=True, add_change_event=True)[source]

Add a contained child widget.

If gui_values_path is False or None, do not add it to the GUI values table; if it is True, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise, gui_values_path specifies the path under which the widget values are stored. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

get_child(name)[source]

Get the child widget with the given name

remove_child(name, clear=True)[source]

Remove child from the container and (if clear==True) clear it

add_virtual_element(name, value=None, multivalued=False, add_indicator=True)[source]

Add a virtual value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view (its value can be set or read, it has on-change events, it can have indicator). The element value is simply stored on set and retrieved on get. If multivalued==True, the internal value is assumed to be complex, so it is forced to be a Dictionary every time it is set. If add_indicator==True, add default indicator handler as well.

add_property_element(name, getter=None, setter=None, add_indicator=True)[source]

Add a property value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view; each time the value is set or get, the corresponding setter and getter methods are called. If add_indicator==True, add default (stored value) indicator handler as well.

start()

Start the container.

Starts all the internal timers, and calls start method for all the contained widgets.

stop()

Stop the container.

Stops all the internal timers, and calls stop method for all the contained widgets.

is_running()[source]

Check if the container is running (started and not yet stopped)

is_stopping()[source]

Check if the container is stopping (stopping initialized and not yet done)

clear()[source]

Clear the container.

Stop all timers and widgets, and call clear methods of all contained widgets, remove all widgets from the values table, remove all widgets from the table.

get_handler(name)[source]

Get value handler of a widget with the given name

get_widget(name)[source]

Get a widget corresponding to a value with the given name

get_value(name=None)[source]

Get value of a widget with the given name (None means all values)

get_all_values()[source]

Get values of all widget in the container

set_value(name, value)[source]

Set value of a widget with the given name (None means all values)

set_all_values(value)[source]

Set values of all widgets in the container

get_value_changed_signal(name)[source]

Get a value-changed signal for a widget with the given name

update_value(name=None)[source]

Send update signal for a handler with a given name or list of names.

Emit a value changed signal with the current value to notify the subscribed slots. If name is None, emit for all values in the table.

get_indicator(name=None)[source]

Get indicator value for a widget with the given name (None means all indicators)

get_all_indicators()[source]

Get indicator values of all widget in the container

set_indicator(name, value, ignore_missing=False)[source]

Set indicator value for a widget or a branch with the given name

set_all_indicators(value, ignore_missing=True)[source]
update_indicators()[source]

Update all indicators to represent current values

class pylablib.core.gui.widgets.container.QContainer(*args, name=None, **kwargs)[source]

Bases: IQContainer, object

Basic controller object which combines and controls several other widget.

Can either corresponds to a widget (e.g., a frame or a group box), or simply be an organizing entity.

Parameters:

name – entity name (used by default when adding this object to a values table)

Simply a combination of IQContainer and QObject.

TimerUIDGenerator = <pylablib.core.utils.general.NamedUIDGenerator object>
add_child(name, widget, gui_values_path=True, add_change_event=True)

Add a contained child widget.

If gui_values_path is False or None, do not add it to the GUI values table; if it is True, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise, gui_values_path specifies the path under which the widget values are stored. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_child_values(name, widget, path, add_change_event=True)

Add child’s values to the container’s table.

If widget is a container and path=="" or ends in "/*" (e.g., "subpath/*"), use its setup_gui_values to make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_property_element(name, getter=None, setter=None, add_indicator=True)

Add a property value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view; each time the value is set or get, the corresponding setter and getter methods are called. If add_indicator==True, add default (stored value) indicator handler as well.

add_timer(name, period, autostart=True)

Add a periodic timer with the given name and period.

Rarely needs to be called explicitly (one is created automatically if timer event is created). If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_timer_event(name, loop=None, start=None, stop=None, period=None, timer=None, autostart=True)

Add timer event with the given name.

Add an event which should be called periodically (e.g., a GUI update). Internally implemented through Qt timers. loop, start and stop are the functions called, correspondingly, on timer (periodically), when timer is start, and when it’s finished. One can either specify the timer by name (timer parameter), or create a new one with the given period. If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_virtual_element(name, value=None, multivalued=False, add_indicator=True)

Add a virtual value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view (its value can be set or read, it has on-change events, it can have indicator). The element value is simply stored on set and retrieved on get. If multivalued==True, the internal value is assumed to be complex, so it is forced to be a Dictionary every time it is set. If add_indicator==True, add default indicator handler as well.

clear()

Clear the container.

Stop all timers and widgets, and call clear methods of all contained widgets, remove all widgets from the values table, remove all widgets from the table.

contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
get_all_indicators()

Get indicator values of all widget in the container

get_all_values()

Get values of all widget in the container

get_child(name)

Get the child widget with the given name

get_handler(name)

Get value handler of a widget with the given name

get_indicator(name=None)

Get indicator value for a widget with the given name (None means all indicators)

get_value(name=None)

Get value of a widget with the given name (None means all values)

get_value_changed_signal(name)

Get a value-changed signal for a widget with the given name

get_widget(name)

Get a widget corresponding to a value with the given name

is_running()

Check if the container is running (started and not yet stopped)

is_stopping()

Check if the container is stopping (stopping initialized and not yet done)

is_timer_running(name)

Check if the timer with the given name is running

remove_child(name, clear=True)

Remove child from the container and (if clear==True) clear it

set_all_indicators(value, ignore_missing=True)
set_all_values(value)

Set values of all widgets in the container

set_indicator(name, value, ignore_missing=False)

Set indicator value for a widget or a branch with the given name

set_value(name, value)

Set value of a widget with the given name (None means all values)

setup(name=None)

Setup the container by initializing its GUI values and setting the ctl attribute

setup_name(name)

Set the object’s name

start()

Start the container.

Starts all the internal timers, and calls start method for all the contained widgets.

start_timer(name)

Start the timer with the given name (also called automatically on start() method)

stop()

Stop the container.

Stops all the internal timers, and calls stop method for all the contained widgets.

stop_timer(name)

Stop the timer with the given name (also called automatically on stop() method)

update_indicators()

Update all indicators to represent current values

update_value(name=None)

Send update signal for a handler with a given name or list of names.

Emit a value changed signal with the current value to notify the subscribed slots. If name is None, emit for all values in the table.

class pylablib.core.gui.widgets.container.IQWidgetContainer(*args, **kwargs)[source]

Bases: IQLayoutManagedWidget, IQContainer

Generic widget container.

Combines IQContainer management of GUI values and timers with IQLayoutManagedWidget management of the contained widget’s layout.

Typically, adding widget adds them both to the container values and to the layout; however, this can be skipped by either using QLayoutManagedWidget.add_to_layout() (only add to the layout), or specifying location="skip" in add_child() (only add to the container).

Abstract mix-in class, which needs to be added to a class inheriting from QWidget. Alternatively, one can directly use QWidgetContainer, which already inherits from QWidget.

setup(layout='vbox', no_margins=False, name=None)[source]

Setup the layout.

Parameters:
  • layout – layout kind; can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

  • no_margins – if True, set all layout margins to zero (useful when the widget is in the middle of layout hierarchy)

add_child(name, widget, location=None, gui_values_path=True)[source]

Add a contained child widget.

name specifies the child storage name; if name==False, only add the widget to they layout, but not to the container. location specifies the layout location to which the widget is added; if location=="skip", skip adding it to the layout (can be manually added later). Note that if the widget is added to the layout, it will be completely deleted when clear or remove_child methods are called; otherwise, simply its clear method will be called, and its GUI values will be deleted.

If gui_values_path is False or None, do not add it to the GUI values table; if it is True, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise, gui_values_path specifies the path under which the widget values are stored.

remove_child(name, clear=True)[source]

Remove widget from the container and the layout and (if clear==True) clear it, and remove it

add_frame(name, layout='vbox', location=None, gui_values_path=True, no_margins=True)[source]

Add a new frame container to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

add_group_box(name, caption, layout='vbox', location=None, gui_values_path=True, no_margins=True)[source]

Add a new group box container with the given caption to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

clear()[source]

Clear the container.

All the timers are stopped, all the contained widgets are cleared and removed.

TimerUIDGenerator = <pylablib.core.utils.general.NamedUIDGenerator object>
add_child_values(name, widget, path, add_change_event=True)

Add child’s values to the container’s table.

If widget is a container and path=="" or ends in "/*" (e.g., "subpath/*"), use its setup_gui_values to make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_decoration_label(text, location='next')

Add a decoration text label with the given text

add_padding(kind='auto', location='next', stretch=0)

Add a padding (expandable spacer) of the given kind to the given location.

kind can be "vertical", "horizontal", "auto" (vertical for grid and vbox layouts, horizontal for hbox), or "both" (stretches in both directions). If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); can also be a tuple with two stretches along vertical and horizontal directions.

add_property_element(name, getter=None, setter=None, add_indicator=True)

Add a property value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view; each time the value is set or get, the corresponding setter and getter methods are called. If add_indicator==True, add default (stored value) indicator handler as well.

add_spacer(height=0, width=0, stretch_height=False, stretch_width=False, stretch=0, location='next')

Add a spacer with the given width and height to the given location.

If stretch_height==True or stretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); if kind==”both”`, it can also be a tuple with two stretches along vertical and horizontal directions.

add_sublayout(name, kind='grid', location=None)

Add a sublayout to the given location.

name specifies the sublayout name, which can be used to refer to it in specifying locations later. kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

add_timer(name, period, autostart=True)

Add a periodic timer with the given name and period.

Rarely needs to be called explicitly (one is created automatically if timer event is created). If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_timer_event(name, loop=None, start=None, stop=None, period=None, timer=None, autostart=True)

Add timer event with the given name.

Add an event which should be called periodically (e.g., a GUI update). Internally implemented through Qt timers. loop, start and stop are the functions called, correspondingly, on timer (periodically), when timer is start, and when it’s finished. One can either specify the timer by name (timer parameter), or create a new one with the given period. If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_to_layout(element, location=None, kind='widget')

Add an existing element to the layout at the given location.

kind can be "widget" for widgets, "layout" for other layouts, or "item" for layout items (spacers).

add_virtual_element(name, value=None, multivalued=False, add_indicator=True)

Add a virtual value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view (its value can be set or read, it has on-change events, it can have indicator). The element value is simply stored on set and retrieved on get. If multivalued==True, the internal value is assumed to be complex, so it is forced to be a Dictionary every time it is set. If add_indicator==True, add default indicator handler as well.

contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
get_all_indicators()

Get indicator values of all widget in the container

get_all_values()

Get values of all widget in the container

get_child(name)

Get the child widget with the given name

get_element_position(element)

Get the sublayout and the position of the given widget.

Return tuple (sublayout, location), where sublayout is the sublayout name ("name" for the main layout), and location is a tuple (row, column, rowspan, colspan). If the given widget is not in this layout, return None.

get_handler(name)

Get value handler of a widget with the given name

get_indicator(name=None)

Get indicator value for a widget with the given name (None means all indicators)

get_layout_shape(name=None)

Get shape (rows, cols) of the current layout

get_sublayout(name=None)

Get the previously added sublayout

get_sublayout_kind(name=None)

Get the kind of the previously added sublayout

get_value(name=None)

Get value of a widget with the given name (None means all values)

get_value_changed_signal(name)

Get a value-changed signal for a widget with the given name

get_widget(name)

Get a widget corresponding to a value with the given name

insert_column(col, sublayout=None, stretch=0)

Insert a new column at the given location in the grid layout

insert_row(row, sublayout=None, stretch=0)

Insert a new row at the given location in the grid layout

is_running()

Check if the container is running (started and not yet stopped)

is_stopping()

Check if the container is stopping (stopping initialized and not yet done)

is_timer_running(name)

Check if the timer with the given name is running

iter_sublayout_items(name=None, include=('widget',), nested=False)

Iterate over items contained in a given sublayout.

include is a tuple which contains items to iterate over; can include "widget" or "layout". If nested==True, iterate over items in contained layouts as well.

remove_layout_element(element)

Remove a previously added layout element

set_all_indicators(value, ignore_missing=True)
set_all_values(value)

Set values of all widgets in the container

set_column_stretch(*args, layout=None)

Set column stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all columns.

set_indicator(name, value, ignore_missing=False)

Set indicator value for a widget or a branch with the given name

set_row_stretch(*args, layout=None)

Set row stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all rows.

set_value(name, value)

Set value of a widget with the given name (None means all values)

setup_name(name)

Set the object’s name

start()

Start the container.

Starts all the internal timers, and calls start method for all the contained widgets.

start_timer(name)

Start the timer with the given name (also called automatically on start() method)

stop()

Stop the container.

Stops all the internal timers, and calls stop method for all the contained widgets.

stop_timer(name)

Stop the timer with the given name (also called automatically on stop() method)

update_indicators()

Update all indicators to represent current values

update_value(name=None)

Send update signal for a handler with a given name or list of names.

Emit a value changed signal with the current value to notify the subscribed slots. If name is None, emit for all values in the table.

using_layout(name)

Use a different sublayout as default inside the with block

using_new_sublayout(name, kind='grid', location=None)

Create a different sublayout and use it as default inside the with block.

kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

class pylablib.core.gui.widgets.container.QWidgetContainer(*args, **kwargs)[source]

Bases: IQWidgetContainer, object

Generic widget container.

Combines IQContainer management of GUI values and timers with IQLayoutManagedWidget management of the contained widget’s layout.

Typically, adding widget adds them both to the container values and to the layout; however, this can be skipped by either using QLayoutManagedWidget.add_to_layout() (only add to the layout), or specifying location="skip" in add_child() (only add to the container).

Simply a combination of IQWidgetContainer and QWidget.

TimerUIDGenerator = <pylablib.core.utils.general.NamedUIDGenerator object>
add_child(name, widget, location=None, gui_values_path=True)

Add a contained child widget.

name specifies the child storage name; if name==False, only add the widget to they layout, but not to the container. location specifies the layout location to which the widget is added; if location=="skip", skip adding it to the layout (can be manually added later). Note that if the widget is added to the layout, it will be completely deleted when clear or remove_child methods are called; otherwise, simply its clear method will be called, and its GUI values will be deleted.

If gui_values_path is False or None, do not add it to the GUI values table; if it is True, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise, gui_values_path specifies the path under which the widget values are stored.

add_child_values(name, widget, path, add_change_event=True)

Add child’s values to the container’s table.

If widget is a container and path=="" or ends in "/*" (e.g., "subpath/*"), use its setup_gui_values to make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_decoration_label(text, location='next')

Add a decoration text label with the given text

add_frame(name, layout='vbox', location=None, gui_values_path=True, no_margins=True)

Add a new frame container to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

add_group_box(name, caption, layout='vbox', location=None, gui_values_path=True, no_margins=True)

Add a new group box container with the given caption to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

add_padding(kind='auto', location='next', stretch=0)

Add a padding (expandable spacer) of the given kind to the given location.

kind can be "vertical", "horizontal", "auto" (vertical for grid and vbox layouts, horizontal for hbox), or "both" (stretches in both directions). If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); can also be a tuple with two stretches along vertical and horizontal directions.

add_property_element(name, getter=None, setter=None, add_indicator=True)

Add a property value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view; each time the value is set or get, the corresponding setter and getter methods are called. If add_indicator==True, add default (stored value) indicator handler as well.

add_spacer(height=0, width=0, stretch_height=False, stretch_width=False, stretch=0, location='next')

Add a spacer with the given width and height to the given location.

If stretch_height==True or stretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); if kind==”both”`, it can also be a tuple with two stretches along vertical and horizontal directions.

add_sublayout(name, kind='grid', location=None)

Add a sublayout to the given location.

name specifies the sublayout name, which can be used to refer to it in specifying locations later. kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

add_timer(name, period, autostart=True)

Add a periodic timer with the given name and period.

Rarely needs to be called explicitly (one is created automatically if timer event is created). If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_timer_event(name, loop=None, start=None, stop=None, period=None, timer=None, autostart=True)

Add timer event with the given name.

Add an event which should be called periodically (e.g., a GUI update). Internally implemented through Qt timers. loop, start and stop are the functions called, correspondingly, on timer (periodically), when timer is start, and when it’s finished. One can either specify the timer by name (timer parameter), or create a new one with the given period. If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_to_layout(element, location=None, kind='widget')

Add an existing element to the layout at the given location.

kind can be "widget" for widgets, "layout" for other layouts, or "item" for layout items (spacers).

add_virtual_element(name, value=None, multivalued=False, add_indicator=True)

Add a virtual value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view (its value can be set or read, it has on-change events, it can have indicator). The element value is simply stored on set and retrieved on get. If multivalued==True, the internal value is assumed to be complex, so it is forced to be a Dictionary every time it is set. If add_indicator==True, add default indicator handler as well.

clear()

Clear the container.

All the timers are stopped, all the contained widgets are cleared and removed.

contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
get_all_indicators()

Get indicator values of all widget in the container

get_all_values()

Get values of all widget in the container

get_child(name)

Get the child widget with the given name

get_element_position(element)

Get the sublayout and the position of the given widget.

Return tuple (sublayout, location), where sublayout is the sublayout name ("name" for the main layout), and location is a tuple (row, column, rowspan, colspan). If the given widget is not in this layout, return None.

get_handler(name)

Get value handler of a widget with the given name

get_indicator(name=None)

Get indicator value for a widget with the given name (None means all indicators)

get_layout_shape(name=None)

Get shape (rows, cols) of the current layout

get_sublayout(name=None)

Get the previously added sublayout

get_sublayout_kind(name=None)

Get the kind of the previously added sublayout

get_value(name=None)

Get value of a widget with the given name (None means all values)

get_value_changed_signal(name)

Get a value-changed signal for a widget with the given name

get_widget(name)

Get a widget corresponding to a value with the given name

insert_column(col, sublayout=None, stretch=0)

Insert a new column at the given location in the grid layout

insert_row(row, sublayout=None, stretch=0)

Insert a new row at the given location in the grid layout

is_running()

Check if the container is running (started and not yet stopped)

is_stopping()

Check if the container is stopping (stopping initialized and not yet done)

is_timer_running(name)

Check if the timer with the given name is running

iter_sublayout_items(name=None, include=('widget',), nested=False)

Iterate over items contained in a given sublayout.

include is a tuple which contains items to iterate over; can include "widget" or "layout". If nested==True, iterate over items in contained layouts as well.

remove_child(name, clear=True)

Remove widget from the container and the layout and (if clear==True) clear it, and remove it

remove_layout_element(element)

Remove a previously added layout element

set_all_indicators(value, ignore_missing=True)
set_all_values(value)

Set values of all widgets in the container

set_column_stretch(*args, layout=None)

Set column stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all columns.

set_indicator(name, value, ignore_missing=False)

Set indicator value for a widget or a branch with the given name

set_row_stretch(*args, layout=None)

Set row stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all rows.

set_value(name, value)

Set value of a widget with the given name (None means all values)

setup(layout='vbox', no_margins=False, name=None)

Setup the layout.

Parameters:
  • layout – layout kind; can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

  • no_margins – if True, set all layout margins to zero (useful when the widget is in the middle of layout hierarchy)

setup_name(name)

Set the object’s name

start()

Start the container.

Starts all the internal timers, and calls start method for all the contained widgets.

start_timer(name)

Start the timer with the given name (also called automatically on start() method)

stop()

Stop the container.

Stops all the internal timers, and calls stop method for all the contained widgets.

stop_timer(name)

Stop the timer with the given name (also called automatically on stop() method)

update_indicators()

Update all indicators to represent current values

update_value(name=None)

Send update signal for a handler with a given name or list of names.

Emit a value changed signal with the current value to notify the subscribed slots. If name is None, emit for all values in the table.

using_layout(name)

Use a different sublayout as default inside the with block

using_new_sublayout(name, kind='grid', location=None)

Create a different sublayout and use it as default inside the with block.

kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

class pylablib.core.gui.widgets.container.QFrameContainer(*args, **kwargs)[source]

Bases: IQWidgetContainer, object

An extension of IQWidgetContainer for a QFrame Qt base class

TimerUIDGenerator = <pylablib.core.utils.general.NamedUIDGenerator object>
add_child(name, widget, location=None, gui_values_path=True)

Add a contained child widget.

name specifies the child storage name; if name==False, only add the widget to they layout, but not to the container. location specifies the layout location to which the widget is added; if location=="skip", skip adding it to the layout (can be manually added later). Note that if the widget is added to the layout, it will be completely deleted when clear or remove_child methods are called; otherwise, simply its clear method will be called, and its GUI values will be deleted.

If gui_values_path is False or None, do not add it to the GUI values table; if it is True, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise, gui_values_path specifies the path under which the widget values are stored.

add_child_values(name, widget, path, add_change_event=True)

Add child’s values to the container’s table.

If widget is a container and path=="" or ends in "/*" (e.g., "subpath/*"), use its setup_gui_values to make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_decoration_label(text, location='next')

Add a decoration text label with the given text

add_frame(name, layout='vbox', location=None, gui_values_path=True, no_margins=True)

Add a new frame container to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

add_group_box(name, caption, layout='vbox', location=None, gui_values_path=True, no_margins=True)

Add a new group box container with the given caption to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

add_padding(kind='auto', location='next', stretch=0)

Add a padding (expandable spacer) of the given kind to the given location.

kind can be "vertical", "horizontal", "auto" (vertical for grid and vbox layouts, horizontal for hbox), or "both" (stretches in both directions). If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); can also be a tuple with two stretches along vertical and horizontal directions.

add_property_element(name, getter=None, setter=None, add_indicator=True)

Add a property value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view; each time the value is set or get, the corresponding setter and getter methods are called. If add_indicator==True, add default (stored value) indicator handler as well.

add_spacer(height=0, width=0, stretch_height=False, stretch_width=False, stretch=0, location='next')

Add a spacer with the given width and height to the given location.

If stretch_height==True or stretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); if kind==”both”`, it can also be a tuple with two stretches along vertical and horizontal directions.

add_sublayout(name, kind='grid', location=None)

Add a sublayout to the given location.

name specifies the sublayout name, which can be used to refer to it in specifying locations later. kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

add_timer(name, period, autostart=True)

Add a periodic timer with the given name and period.

Rarely needs to be called explicitly (one is created automatically if timer event is created). If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_timer_event(name, loop=None, start=None, stop=None, period=None, timer=None, autostart=True)

Add timer event with the given name.

Add an event which should be called periodically (e.g., a GUI update). Internally implemented through Qt timers. loop, start and stop are the functions called, correspondingly, on timer (periodically), when timer is start, and when it’s finished. One can either specify the timer by name (timer parameter), or create a new one with the given period. If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_to_layout(element, location=None, kind='widget')

Add an existing element to the layout at the given location.

kind can be "widget" for widgets, "layout" for other layouts, or "item" for layout items (spacers).

add_virtual_element(name, value=None, multivalued=False, add_indicator=True)

Add a virtual value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view (its value can be set or read, it has on-change events, it can have indicator). The element value is simply stored on set and retrieved on get. If multivalued==True, the internal value is assumed to be complex, so it is forced to be a Dictionary every time it is set. If add_indicator==True, add default indicator handler as well.

clear()

Clear the container.

All the timers are stopped, all the contained widgets are cleared and removed.

contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
get_all_indicators()

Get indicator values of all widget in the container

get_all_values()

Get values of all widget in the container

get_child(name)

Get the child widget with the given name

get_element_position(element)

Get the sublayout and the position of the given widget.

Return tuple (sublayout, location), where sublayout is the sublayout name ("name" for the main layout), and location is a tuple (row, column, rowspan, colspan). If the given widget is not in this layout, return None.

get_handler(name)

Get value handler of a widget with the given name

get_indicator(name=None)

Get indicator value for a widget with the given name (None means all indicators)

get_layout_shape(name=None)

Get shape (rows, cols) of the current layout

get_sublayout(name=None)

Get the previously added sublayout

get_sublayout_kind(name=None)

Get the kind of the previously added sublayout

get_value(name=None)

Get value of a widget with the given name (None means all values)

get_value_changed_signal(name)

Get a value-changed signal for a widget with the given name

get_widget(name)

Get a widget corresponding to a value with the given name

insert_column(col, sublayout=None, stretch=0)

Insert a new column at the given location in the grid layout

insert_row(row, sublayout=None, stretch=0)

Insert a new row at the given location in the grid layout

is_running()

Check if the container is running (started and not yet stopped)

is_stopping()

Check if the container is stopping (stopping initialized and not yet done)

is_timer_running(name)

Check if the timer with the given name is running

iter_sublayout_items(name=None, include=('widget',), nested=False)

Iterate over items contained in a given sublayout.

include is a tuple which contains items to iterate over; can include "widget" or "layout". If nested==True, iterate over items in contained layouts as well.

remove_child(name, clear=True)

Remove widget from the container and the layout and (if clear==True) clear it, and remove it

remove_layout_element(element)

Remove a previously added layout element

set_all_indicators(value, ignore_missing=True)
set_all_values(value)

Set values of all widgets in the container

set_column_stretch(*args, layout=None)

Set column stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all columns.

set_indicator(name, value, ignore_missing=False)

Set indicator value for a widget or a branch with the given name

set_row_stretch(*args, layout=None)

Set row stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all rows.

set_value(name, value)

Set value of a widget with the given name (None means all values)

setup(layout='vbox', no_margins=False, name=None)

Setup the layout.

Parameters:
  • layout – layout kind; can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

  • no_margins – if True, set all layout margins to zero (useful when the widget is in the middle of layout hierarchy)

setup_name(name)

Set the object’s name

start()

Start the container.

Starts all the internal timers, and calls start method for all the contained widgets.

start_timer(name)

Start the timer with the given name (also called automatically on start() method)

stop()

Stop the container.

Stops all the internal timers, and calls stop method for all the contained widgets.

stop_timer(name)

Stop the timer with the given name (also called automatically on stop() method)

update_indicators()

Update all indicators to represent current values

update_value(name=None)

Send update signal for a handler with a given name or list of names.

Emit a value changed signal with the current value to notify the subscribed slots. If name is None, emit for all values in the table.

using_layout(name)

Use a different sublayout as default inside the with block

using_new_sublayout(name, kind='grid', location=None)

Create a different sublayout and use it as default inside the with block.

kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

class pylablib.core.gui.widgets.container.QDialogContainer(*args, **kwargs)[source]

Bases: IQWidgetContainer, object

An extension of IQWidgetContainer for a QDialog Qt base class

TimerUIDGenerator = <pylablib.core.utils.general.NamedUIDGenerator object>
add_child(name, widget, location=None, gui_values_path=True)

Add a contained child widget.

name specifies the child storage name; if name==False, only add the widget to they layout, but not to the container. location specifies the layout location to which the widget is added; if location=="skip", skip adding it to the layout (can be manually added later). Note that if the widget is added to the layout, it will be completely deleted when clear or remove_child methods are called; otherwise, simply its clear method will be called, and its GUI values will be deleted.

If gui_values_path is False or None, do not add it to the GUI values table; if it is True, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise, gui_values_path specifies the path under which the widget values are stored.

add_child_values(name, widget, path, add_change_event=True)

Add child’s values to the container’s table.

If widget is a container and path=="" or ends in "/*" (e.g., "subpath/*"), use its setup_gui_values to make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_decoration_label(text, location='next')

Add a decoration text label with the given text

add_frame(name, layout='vbox', location=None, gui_values_path=True, no_margins=True)

Add a new frame container to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

add_group_box(name, caption, layout='vbox', location=None, gui_values_path=True, no_margins=True)

Add a new group box container with the given caption to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

add_padding(kind='auto', location='next', stretch=0)

Add a padding (expandable spacer) of the given kind to the given location.

kind can be "vertical", "horizontal", "auto" (vertical for grid and vbox layouts, horizontal for hbox), or "both" (stretches in both directions). If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); can also be a tuple with two stretches along vertical and horizontal directions.

add_property_element(name, getter=None, setter=None, add_indicator=True)

Add a property value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view; each time the value is set or get, the corresponding setter and getter methods are called. If add_indicator==True, add default (stored value) indicator handler as well.

add_spacer(height=0, width=0, stretch_height=False, stretch_width=False, stretch=0, location='next')

Add a spacer with the given width and height to the given location.

If stretch_height==True or stretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); if kind==”both”`, it can also be a tuple with two stretches along vertical and horizontal directions.

add_sublayout(name, kind='grid', location=None)

Add a sublayout to the given location.

name specifies the sublayout name, which can be used to refer to it in specifying locations later. kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

add_timer(name, period, autostart=True)

Add a periodic timer with the given name and period.

Rarely needs to be called explicitly (one is created automatically if timer event is created). If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_timer_event(name, loop=None, start=None, stop=None, period=None, timer=None, autostart=True)

Add timer event with the given name.

Add an event which should be called periodically (e.g., a GUI update). Internally implemented through Qt timers. loop, start and stop are the functions called, correspondingly, on timer (periodically), when timer is start, and when it’s finished. One can either specify the timer by name (timer parameter), or create a new one with the given period. If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_to_layout(element, location=None, kind='widget')

Add an existing element to the layout at the given location.

kind can be "widget" for widgets, "layout" for other layouts, or "item" for layout items (spacers).

add_virtual_element(name, value=None, multivalued=False, add_indicator=True)

Add a virtual value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view (its value can be set or read, it has on-change events, it can have indicator). The element value is simply stored on set and retrieved on get. If multivalued==True, the internal value is assumed to be complex, so it is forced to be a Dictionary every time it is set. If add_indicator==True, add default indicator handler as well.

clear()

Clear the container.

All the timers are stopped, all the contained widgets are cleared and removed.

contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
get_all_indicators()

Get indicator values of all widget in the container

get_all_values()

Get values of all widget in the container

get_child(name)

Get the child widget with the given name

get_element_position(element)

Get the sublayout and the position of the given widget.

Return tuple (sublayout, location), where sublayout is the sublayout name ("name" for the main layout), and location is a tuple (row, column, rowspan, colspan). If the given widget is not in this layout, return None.

get_handler(name)

Get value handler of a widget with the given name

get_indicator(name=None)

Get indicator value for a widget with the given name (None means all indicators)

get_layout_shape(name=None)

Get shape (rows, cols) of the current layout

get_sublayout(name=None)

Get the previously added sublayout

get_sublayout_kind(name=None)

Get the kind of the previously added sublayout

get_value(name=None)

Get value of a widget with the given name (None means all values)

get_value_changed_signal(name)

Get a value-changed signal for a widget with the given name

get_widget(name)

Get a widget corresponding to a value with the given name

insert_column(col, sublayout=None, stretch=0)

Insert a new column at the given location in the grid layout

insert_row(row, sublayout=None, stretch=0)

Insert a new row at the given location in the grid layout

is_running()

Check if the container is running (started and not yet stopped)

is_stopping()

Check if the container is stopping (stopping initialized and not yet done)

is_timer_running(name)

Check if the timer with the given name is running

iter_sublayout_items(name=None, include=('widget',), nested=False)

Iterate over items contained in a given sublayout.

include is a tuple which contains items to iterate over; can include "widget" or "layout". If nested==True, iterate over items in contained layouts as well.

remove_child(name, clear=True)

Remove widget from the container and the layout and (if clear==True) clear it, and remove it

remove_layout_element(element)

Remove a previously added layout element

set_all_indicators(value, ignore_missing=True)
set_all_values(value)

Set values of all widgets in the container

set_column_stretch(*args, layout=None)

Set column stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all columns.

set_indicator(name, value, ignore_missing=False)

Set indicator value for a widget or a branch with the given name

set_row_stretch(*args, layout=None)

Set row stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all rows.

set_value(name, value)

Set value of a widget with the given name (None means all values)

setup(layout='vbox', no_margins=False, name=None)

Setup the layout.

Parameters:
  • layout – layout kind; can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

  • no_margins – if True, set all layout margins to zero (useful when the widget is in the middle of layout hierarchy)

setup_name(name)

Set the object’s name

start()

Start the container.

Starts all the internal timers, and calls start method for all the contained widgets.

start_timer(name)

Start the timer with the given name (also called automatically on start() method)

stop()

Stop the container.

Stops all the internal timers, and calls stop method for all the contained widgets.

stop_timer(name)

Stop the timer with the given name (also called automatically on stop() method)

update_indicators()

Update all indicators to represent current values

update_value(name=None)

Send update signal for a handler with a given name or list of names.

Emit a value changed signal with the current value to notify the subscribed slots. If name is None, emit for all values in the table.

using_layout(name)

Use a different sublayout as default inside the with block

using_new_sublayout(name, kind='grid', location=None)

Create a different sublayout and use it as default inside the with block.

kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

class pylablib.core.gui.widgets.container.QGroupBoxContainer(*args, **kwargs)[source]

Bases: IQWidgetContainer, object

An extension of IQWidgetContainer for a QGroupBox Qt base class

setup(caption=None, layout='vbox', no_margins=False, name=None)[source]

Setup the layout.

Parameters:
  • layout – layout kind; can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

  • no_margins – if True, set all layout margins to zero (useful when the widget is in the middle of layout hierarchy)

TimerUIDGenerator = <pylablib.core.utils.general.NamedUIDGenerator object>
add_child(name, widget, location=None, gui_values_path=True)

Add a contained child widget.

name specifies the child storage name; if name==False, only add the widget to they layout, but not to the container. location specifies the layout location to which the widget is added; if location=="skip", skip adding it to the layout (can be manually added later). Note that if the widget is added to the layout, it will be completely deleted when clear or remove_child methods are called; otherwise, simply its clear method will be called, and its GUI values will be deleted.

If gui_values_path is False or None, do not add it to the GUI values table; if it is True, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise, gui_values_path specifies the path under which the widget values are stored.

add_child_values(name, widget, path, add_change_event=True)

Add child’s values to the container’s table.

If widget is a container and path=="" or ends in "/*" (e.g., "subpath/*"), use its setup_gui_values to make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_decoration_label(text, location='next')

Add a decoration text label with the given text

add_frame(name, layout='vbox', location=None, gui_values_path=True, no_margins=True)

Add a new frame container to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

add_group_box(name, caption, layout='vbox', location=None, gui_values_path=True, no_margins=True)

Add a new group box container with the given caption to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

add_padding(kind='auto', location='next', stretch=0)

Add a padding (expandable spacer) of the given kind to the given location.

kind can be "vertical", "horizontal", "auto" (vertical for grid and vbox layouts, horizontal for hbox), or "both" (stretches in both directions). If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); can also be a tuple with two stretches along vertical and horizontal directions.

add_property_element(name, getter=None, setter=None, add_indicator=True)

Add a property value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view; each time the value is set or get, the corresponding setter and getter methods are called. If add_indicator==True, add default (stored value) indicator handler as well.

add_spacer(height=0, width=0, stretch_height=False, stretch_width=False, stretch=0, location='next')

Add a spacer with the given width and height to the given location.

If stretch_height==True or stretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); if kind==”both”`, it can also be a tuple with two stretches along vertical and horizontal directions.

add_sublayout(name, kind='grid', location=None)

Add a sublayout to the given location.

name specifies the sublayout name, which can be used to refer to it in specifying locations later. kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

add_timer(name, period, autostart=True)

Add a periodic timer with the given name and period.

Rarely needs to be called explicitly (one is created automatically if timer event is created). If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_timer_event(name, loop=None, start=None, stop=None, period=None, timer=None, autostart=True)

Add timer event with the given name.

Add an event which should be called periodically (e.g., a GUI update). Internally implemented through Qt timers. loop, start and stop are the functions called, correspondingly, on timer (periodically), when timer is start, and when it’s finished. One can either specify the timer by name (timer parameter), or create a new one with the given period. If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_to_layout(element, location=None, kind='widget')

Add an existing element to the layout at the given location.

kind can be "widget" for widgets, "layout" for other layouts, or "item" for layout items (spacers).

add_virtual_element(name, value=None, multivalued=False, add_indicator=True)

Add a virtual value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view (its value can be set or read, it has on-change events, it can have indicator). The element value is simply stored on set and retrieved on get. If multivalued==True, the internal value is assumed to be complex, so it is forced to be a Dictionary every time it is set. If add_indicator==True, add default indicator handler as well.

clear()

Clear the container.

All the timers are stopped, all the contained widgets are cleared and removed.

contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
get_all_indicators()

Get indicator values of all widget in the container

get_all_values()

Get values of all widget in the container

get_child(name)

Get the child widget with the given name

get_element_position(element)

Get the sublayout and the position of the given widget.

Return tuple (sublayout, location), where sublayout is the sublayout name ("name" for the main layout), and location is a tuple (row, column, rowspan, colspan). If the given widget is not in this layout, return None.

get_handler(name)

Get value handler of a widget with the given name

get_indicator(name=None)

Get indicator value for a widget with the given name (None means all indicators)

get_layout_shape(name=None)

Get shape (rows, cols) of the current layout

get_sublayout(name=None)

Get the previously added sublayout

get_sublayout_kind(name=None)

Get the kind of the previously added sublayout

get_value(name=None)

Get value of a widget with the given name (None means all values)

get_value_changed_signal(name)

Get a value-changed signal for a widget with the given name

get_widget(name)

Get a widget corresponding to a value with the given name

insert_column(col, sublayout=None, stretch=0)

Insert a new column at the given location in the grid layout

insert_row(row, sublayout=None, stretch=0)

Insert a new row at the given location in the grid layout

is_running()

Check if the container is running (started and not yet stopped)

is_stopping()

Check if the container is stopping (stopping initialized and not yet done)

is_timer_running(name)

Check if the timer with the given name is running

iter_sublayout_items(name=None, include=('widget',), nested=False)

Iterate over items contained in a given sublayout.

include is a tuple which contains items to iterate over; can include "widget" or "layout". If nested==True, iterate over items in contained layouts as well.

remove_child(name, clear=True)

Remove widget from the container and the layout and (if clear==True) clear it, and remove it

remove_layout_element(element)

Remove a previously added layout element

set_all_indicators(value, ignore_missing=True)
set_all_values(value)

Set values of all widgets in the container

set_column_stretch(*args, layout=None)

Set column stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all columns.

set_indicator(name, value, ignore_missing=False)

Set indicator value for a widget or a branch with the given name

set_row_stretch(*args, layout=None)

Set row stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all rows.

set_value(name, value)

Set value of a widget with the given name (None means all values)

setup_name(name)

Set the object’s name

start()

Start the container.

Starts all the internal timers, and calls start method for all the contained widgets.

start_timer(name)

Start the timer with the given name (also called automatically on start() method)

stop()

Stop the container.

Stops all the internal timers, and calls stop method for all the contained widgets.

stop_timer(name)

Stop the timer with the given name (also called automatically on stop() method)

update_indicators()

Update all indicators to represent current values

update_value(name=None)

Send update signal for a handler with a given name or list of names.

Emit a value changed signal with the current value to notify the subscribed slots. If name is None, emit for all values in the table.

using_layout(name)

Use a different sublayout as default inside the with block

using_new_sublayout(name, kind='grid', location=None)

Create a different sublayout and use it as default inside the with block.

kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

class pylablib.core.gui.widgets.container.QScrollAreaContainer(*args, name=None, **kwargs)[source]

Bases: IQContainer, object

An extension of IQWidgetContainer for a QScrollArea Qt base class.

Due to Qt organization, this container is “intermediate”: it contains only a single QWidgetContainer widget (named "widget"), which in turn has all of the standard container traits: layout, multiple widgets, etc. Hence, when dealing with any container methods (adding children, changing layout, etc.), this widget (accessible with .widget() method) should be used.

class QContainedWidget(*args, **kwargs)[source]

Bases: QWidgetContainer

resizeEvent(event)
TimerUIDGenerator = <pylablib.core.utils.general.NamedUIDGenerator object>
add_child(name, widget, location=None, gui_values_path=True)

Add a contained child widget.

name specifies the child storage name; if name==False, only add the widget to they layout, but not to the container. location specifies the layout location to which the widget is added; if location=="skip", skip adding it to the layout (can be manually added later). Note that if the widget is added to the layout, it will be completely deleted when clear or remove_child methods are called; otherwise, simply its clear method will be called, and its GUI values will be deleted.

If gui_values_path is False or None, do not add it to the GUI values table; if it is True, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise, gui_values_path specifies the path under which the widget values are stored.

add_child_values(name, widget, path, add_change_event=True)

Add child’s values to the container’s table.

If widget is a container and path=="" or ends in "/*" (e.g., "subpath/*"), use its setup_gui_values to make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_decoration_label(text, location='next')

Add a decoration text label with the given text

add_frame(name, layout='vbox', location=None, gui_values_path=True, no_margins=True)

Add a new frame container to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

add_group_box(name, caption, layout='vbox', location=None, gui_values_path=True, no_margins=True)

Add a new group box container with the given caption to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

add_padding(kind='auto', location='next', stretch=0)

Add a padding (expandable spacer) of the given kind to the given location.

kind can be "vertical", "horizontal", "auto" (vertical for grid and vbox layouts, horizontal for hbox), or "both" (stretches in both directions). If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); can also be a tuple with two stretches along vertical and horizontal directions.

add_property_element(name, getter=None, setter=None, add_indicator=True)

Add a property value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view; each time the value is set or get, the corresponding setter and getter methods are called. If add_indicator==True, add default (stored value) indicator handler as well.

add_spacer(height=0, width=0, stretch_height=False, stretch_width=False, stretch=0, location='next')

Add a spacer with the given width and height to the given location.

If stretch_height==True or stretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); if kind==”both”`, it can also be a tuple with two stretches along vertical and horizontal directions.

add_sublayout(name, kind='grid', location=None)

Add a sublayout to the given location.

name specifies the sublayout name, which can be used to refer to it in specifying locations later. kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

add_timer(name, period, autostart=True)

Add a periodic timer with the given name and period.

Rarely needs to be called explicitly (one is created automatically if timer event is created). If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_timer_event(name, loop=None, start=None, stop=None, period=None, timer=None, autostart=True)

Add timer event with the given name.

Add an event which should be called periodically (e.g., a GUI update). Internally implemented through Qt timers. loop, start and stop are the functions called, correspondingly, on timer (periodically), when timer is start, and when it’s finished. One can either specify the timer by name (timer parameter), or create a new one with the given period. If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_to_layout(element, location=None, kind='widget')

Add an existing element to the layout at the given location.

kind can be "widget" for widgets, "layout" for other layouts, or "item" for layout items (spacers).

add_virtual_element(name, value=None, multivalued=False, add_indicator=True)

Add a virtual value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view (its value can be set or read, it has on-change events, it can have indicator). The element value is simply stored on set and retrieved on get. If multivalued==True, the internal value is assumed to be complex, so it is forced to be a Dictionary every time it is set. If add_indicator==True, add default indicator handler as well.

clear()

Clear the container.

All the timers are stopped, all the contained widgets are cleared and removed.

contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
get_all_indicators()

Get indicator values of all widget in the container

get_all_values()

Get values of all widget in the container

get_child(name)

Get the child widget with the given name

get_element_position(element)

Get the sublayout and the position of the given widget.

Return tuple (sublayout, location), where sublayout is the sublayout name ("name" for the main layout), and location is a tuple (row, column, rowspan, colspan). If the given widget is not in this layout, return None.

get_handler(name)

Get value handler of a widget with the given name

get_indicator(name=None)

Get indicator value for a widget with the given name (None means all indicators)

get_layout_shape(name=None)

Get shape (rows, cols) of the current layout

get_sublayout(name=None)

Get the previously added sublayout

get_sublayout_kind(name=None)

Get the kind of the previously added sublayout

get_value(name=None)

Get value of a widget with the given name (None means all values)

get_value_changed_signal(name)

Get a value-changed signal for a widget with the given name

get_widget(name)

Get a widget corresponding to a value with the given name

insert_column(col, sublayout=None, stretch=0)

Insert a new column at the given location in the grid layout

insert_row(row, sublayout=None, stretch=0)

Insert a new row at the given location in the grid layout

is_running()

Check if the container is running (started and not yet stopped)

is_stopping()

Check if the container is stopping (stopping initialized and not yet done)

is_timer_running(name)

Check if the timer with the given name is running

iter_sublayout_items(name=None, include=('widget',), nested=False)

Iterate over items contained in a given sublayout.

include is a tuple which contains items to iterate over; can include "widget" or "layout". If nested==True, iterate over items in contained layouts as well.

remove_child(name, clear=True)

Remove widget from the container and the layout and (if clear==True) clear it, and remove it

remove_layout_element(element)

Remove a previously added layout element

set_all_indicators(value, ignore_missing=True)
set_all_values(value)

Set values of all widgets in the container

set_column_stretch(*args, layout=None)

Set column stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all columns.

set_indicator(name, value, ignore_missing=False)

Set indicator value for a widget or a branch with the given name

set_row_stretch(*args, layout=None)

Set row stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all rows.

set_value(name, value)

Set value of a widget with the given name (None means all values)

setup(layout='vbox', no_margins=False, name=None)

Setup the layout.

Parameters:
  • layout – layout kind; can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

  • no_margins – if True, set all layout margins to zero (useful when the widget is in the middle of layout hierarchy)

setup_name(name)

Set the object’s name

start()

Start the container.

Starts all the internal timers, and calls start method for all the contained widgets.

start_timer(name)

Start the timer with the given name (also called automatically on start() method)

stop()

Stop the container.

Stops all the internal timers, and calls stop method for all the contained widgets.

stop_timer(name)

Stop the timer with the given name (also called automatically on stop() method)

update_indicators()

Update all indicators to represent current values

update_value(name=None)

Send update signal for a handler with a given name or list of names.

Emit a value changed signal with the current value to notify the subscribed slots. If name is None, emit for all values in the table.

using_layout(name)

Use a different sublayout as default inside the with block

using_new_sublayout(name, kind='grid', location=None)

Create a different sublayout and use it as default inside the with block.

kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

setup(layout='vbox', no_margins=False, name=None, fix_width=True, fix_height=False)[source]

Setup the container.

layout specifies the container layout, no_margins determines whether margins within the container are removed, name specifies the widget name (if not specified yet). fix_width and fix_height determine whether the corresponding direction behaves as a scroll window (i.e., the size is fixed when the content changes), or as a standard widget container (the size is determined by the content).

clear()[source]

Clear the container.

Stop all timers and widgets, and call clear methods of all contained widgets, remove all widgets from the values table, remove all widgets from the table.

TimerUIDGenerator = <pylablib.core.utils.general.NamedUIDGenerator object>
add_child(name, widget, gui_values_path=True, add_change_event=True)

Add a contained child widget.

If gui_values_path is False or None, do not add it to the GUI values table; if it is True, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise, gui_values_path specifies the path under which the widget values are stored. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_child_values(name, widget, path, add_change_event=True)

Add child’s values to the container’s table.

If widget is a container and path=="" or ends in "/*" (e.g., "subpath/*"), use its setup_gui_values to make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_property_element(name, getter=None, setter=None, add_indicator=True)

Add a property value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view; each time the value is set or get, the corresponding setter and getter methods are called. If add_indicator==True, add default (stored value) indicator handler as well.

add_timer(name, period, autostart=True)

Add a periodic timer with the given name and period.

Rarely needs to be called explicitly (one is created automatically if timer event is created). If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_timer_event(name, loop=None, start=None, stop=None, period=None, timer=None, autostart=True)

Add timer event with the given name.

Add an event which should be called periodically (e.g., a GUI update). Internally implemented through Qt timers. loop, start and stop are the functions called, correspondingly, on timer (periodically), when timer is start, and when it’s finished. One can either specify the timer by name (timer parameter), or create a new one with the given period. If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_virtual_element(name, value=None, multivalued=False, add_indicator=True)

Add a virtual value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view (its value can be set or read, it has on-change events, it can have indicator). The element value is simply stored on set and retrieved on get. If multivalued==True, the internal value is assumed to be complex, so it is forced to be a Dictionary every time it is set. If add_indicator==True, add default indicator handler as well.

contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
get_all_indicators()

Get indicator values of all widget in the container

get_all_values()

Get values of all widget in the container

get_child(name)

Get the child widget with the given name

get_handler(name)

Get value handler of a widget with the given name

get_indicator(name=None)

Get indicator value for a widget with the given name (None means all indicators)

get_value(name=None)

Get value of a widget with the given name (None means all values)

get_value_changed_signal(name)

Get a value-changed signal for a widget with the given name

get_widget(name)

Get a widget corresponding to a value with the given name

is_running()

Check if the container is running (started and not yet stopped)

is_stopping()

Check if the container is stopping (stopping initialized and not yet done)

is_timer_running(name)

Check if the timer with the given name is running

remove_child(name, clear=True)

Remove child from the container and (if clear==True) clear it

set_all_indicators(value, ignore_missing=True)
set_all_values(value)

Set values of all widgets in the container

set_indicator(name, value, ignore_missing=False)

Set indicator value for a widget or a branch with the given name

set_value(name, value)

Set value of a widget with the given name (None means all values)

setup_name(name)

Set the object’s name

start()

Start the container.

Starts all the internal timers, and calls start method for all the contained widgets.

start_timer(name)

Start the timer with the given name (also called automatically on start() method)

stop()

Stop the container.

Stops all the internal timers, and calls stop method for all the contained widgets.

stop_timer(name)

Stop the timer with the given name (also called automatically on stop() method)

update_indicators()

Update all indicators to represent current values

update_value(name=None)

Send update signal for a handler with a given name or list of names.

Emit a value changed signal with the current value to notify the subscribed slots. If name is None, emit for all values in the table.

class pylablib.core.gui.widgets.container.QTabContainer(*args, **kwargs)[source]

Bases: IQContainer, object

Container which manages tab widget.

Does not have its own layout, but can add or remove tabs, which are represented as QFrameContainer widgets.

add_tab(name, caption, index=None, widget=None, layout='vbox', gui_values_path=True, no_margins=True)[source]

Add a new tab container with the given caption to the widget.

index specifies the new tab’s index (None means adding to the end, negative values count from the end). If widget is None, create a new frame widget using the given layout ("vbox", "hbox", or "grid") and no_margins (specifies whether the frame has inner margins) arguments; otherwise, use the supplied widget. The other parameters are the same as in add_child() method.

remove_tab(name)[source]

Remove a tab with the given name.

Clear it, remove its GUI values, and delete it and all contained widgets.

clear()[source]

Clear the container.

Stop all timers and widgets, and call clear methods of all contained widgets, remove all widgets from the values table, remove all widgets from the table.

get_current_name()[source]

Get current tab name

set_by_name(name)[source]

Set tab by name

TimerUIDGenerator = <pylablib.core.utils.general.NamedUIDGenerator object>
add_child(name, widget, gui_values_path=True, add_change_event=True)

Add a contained child widget.

If gui_values_path is False or None, do not add it to the GUI values table; if it is True, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise, gui_values_path specifies the path under which the widget values are stored. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_child_values(name, widget, path, add_change_event=True)

Add child’s values to the container’s table.

If widget is a container and path=="" or ends in "/*" (e.g., "subpath/*"), use its setup_gui_values to make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_property_element(name, getter=None, setter=None, add_indicator=True)

Add a property value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view; each time the value is set or get, the corresponding setter and getter methods are called. If add_indicator==True, add default (stored value) indicator handler as well.

add_timer(name, period, autostart=True)

Add a periodic timer with the given name and period.

Rarely needs to be called explicitly (one is created automatically if timer event is created). If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_timer_event(name, loop=None, start=None, stop=None, period=None, timer=None, autostart=True)

Add timer event with the given name.

Add an event which should be called periodically (e.g., a GUI update). Internally implemented through Qt timers. loop, start and stop are the functions called, correspondingly, on timer (periodically), when timer is start, and when it’s finished. One can either specify the timer by name (timer parameter), or create a new one with the given period. If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_virtual_element(name, value=None, multivalued=False, add_indicator=True)

Add a virtual value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view (its value can be set or read, it has on-change events, it can have indicator). The element value is simply stored on set and retrieved on get. If multivalued==True, the internal value is assumed to be complex, so it is forced to be a Dictionary every time it is set. If add_indicator==True, add default indicator handler as well.

contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
get_all_indicators()

Get indicator values of all widget in the container

get_all_values()

Get values of all widget in the container

get_child(name)

Get the child widget with the given name

get_handler(name)

Get value handler of a widget with the given name

get_indicator(name=None)

Get indicator value for a widget with the given name (None means all indicators)

get_value(name=None)

Get value of a widget with the given name (None means all values)

get_value_changed_signal(name)

Get a value-changed signal for a widget with the given name

get_widget(name)

Get a widget corresponding to a value with the given name

is_running()

Check if the container is running (started and not yet stopped)

is_stopping()

Check if the container is stopping (stopping initialized and not yet done)

is_timer_running(name)

Check if the timer with the given name is running

remove_child(name, clear=True)

Remove child from the container and (if clear==True) clear it

set_all_indicators(value, ignore_missing=True)
set_all_values(value)

Set values of all widgets in the container

set_indicator(name, value, ignore_missing=False)

Set indicator value for a widget or a branch with the given name

set_value(name, value)

Set value of a widget with the given name (None means all values)

setup(name=None)

Setup the container by initializing its GUI values and setting the ctl attribute

setup_name(name)

Set the object’s name

start()

Start the container.

Starts all the internal timers, and calls start method for all the contained widgets.

start_timer(name)

Start the timer with the given name (also called automatically on start() method)

stop()

Stop the container.

Stops all the internal timers, and calls stop method for all the contained widgets.

stop_timer(name)

Stop the timer with the given name (also called automatically on stop() method)

update_indicators()

Update all indicators to represent current values

update_value(name=None)

Send update signal for a handler with a given name or list of names.

Emit a value changed signal with the current value to notify the subscribed slots. If name is None, emit for all values in the table.

pylablib.core.gui.widgets.edit module

class pylablib.core.gui.widgets.edit.TextEdit(parent, value=None)[source]

Bases: object

Expanded text edit.

Maintains internally stored consistent value (which can be, e.g., accessed from different threads).

keyPressEvent(event)[source]
set_expandable(left=0, right=0, top=0, bottom=0)[source]

Make text edit expandable.

If it is expandable, the edit size is expanded by the given size into the corresponding directions. If all are zero, the widget behaves as normal.

focusInEvent(evt)[source]
focusOutEvent(evt)[source]
value_entered = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>

Signal emitted when value is entered (regardless of whether it stayed the same)

value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>

Signal emitted when value is changed

get_value()[source]

Get current text value

show_value(interrupt_edit=False)[source]

Display currently stored text value

If interrupt_edit==True and the edit is currently being modified by the user, don’t update the display.

set_value(value, notify_value_change=True, interrupt_edit=False)[source]

Set current text value.

If notify_value_change==True, emit the value_changed signal; otherwise, change value silently. If interrupt_edit==True and the edit is currently being modified by the user, don’t update the display (but still update the internally stored value).

class pylablib.core.gui.widgets.edit.NumEdit(parent, value=None, limiter=None, formatter=None, custom_steps=None)[source]

Bases: object

Labview-style numerical edit.

Maintains internally stored consistent value (which can be, e.g., accessed from different threads). Supports different number representations, metric prefixes (in input or output), keyboard shortcuts (up/down for changing number, escape for cancelling).

Parameters:
  • parent – parent widget

  • value – initial value (None means no value is set)

  • limiter – number limiter (for details, see set_limiter())

  • formatter – number formatter (for details, see set_formatter())

  • custom_steps – if not None, can specify custom fixed value steps when up/down keys are pressed with a modifier key (Control, Alt, or Shift) specifies a dictionary {'ctrl':ctrl_step, 'alt':alt_step, 'shift':shift_step} with the corresponding steps (missing elements mean that the modifier key is ignored)

keyPressEvent(event)[source]
set_limiter(limiter, new_value=None)[source]

Change current numerical limiter.

Limiter can be a callable object which takes a single value and either returns a limited value, or raises limiter.LimitError if it should be ignored; or it can be a tuple (lower, upper, action, value_type), where lower and upper are the limits (None means no limits), action defines out-of-limit action (either "ignore" to ignore entered value, or "coerce" to truncate to the nearest limit), and value_type can be None (keep value as is), "float" (cast value to float), "int" (cast value to int). If the tuple is shorter, the missing parts are filled by default values (None, None, "ignore", None).

set_formatter(formatter)[source]

Change current numerical formatter.

Formatter can be a callable object turning value into a string, a string ("float", "int", or a format string, e.g., ".5f"), or a tuple starting with "float" which contains arguments to the formatter.FloatFormatter.

set_float_formatter(output_format='auto', digits=9, add_trailing_zeros=True, leading_zeros=0, explicit_sign=False)[source]

Set up float formatter.

Has the same functionality as set_formatter() (i.e., set_float_formatter(*args) is equivalent to set_formatter(("float",)+args)), but explicitly lists the arguments.

Parameters:
  • output_format (str) – can be "auto" (use standard Python conversion), "SI" (use SI prefixes if possible), or "sci" (scientific “E” notation).

  • digits (int) – if add_trailing_zeros==False, determines the number of significant digits; otherwise, determines precision (number of digits after decimal point).

  • add_trailing_zeros (bool) – if True, always show fixed number of digits after the decimal point, with zero padding if necessary.

  • leading_zeros (bool) – determines the minimal size of the integer part (before the decimal point) of the number; pads with zeros if necessary.

  • explicit_sign (bool) – if True, always add explicit plus sign.

set_custom_steps(custom_steps=None)[source]

Specify custom fixed value steps when up/down keys are pressed with a modifier key (Control, Alt, or Shift).

custom_steps is a dictionary {'ctrl':ctrl_step, 'alt':alt_step, 'shift':shift_step} with the corresponding steps (missing elements mean that the modifier key is ignored).

get_cursor_order()[source]

Get a decimal order of the text cursor

set_cursor_order(order)[source]

Move text cursor to a given decimal order

repr_value(value)[source]

Return representation of value according to the current numerical format

value_entered = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>

Signal emitted when value is entered (regardless of whether it stayed the same)

value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>

Signal emitted when value is changed

get_value()[source]

Get current numerical value

show_value(interrupt_edit=False, preserve_cursor_order=True)[source]

Display currently stored numerical value

If interrupt_edit==False and the edit is currently being modified by the user, don’t update the display. If preserve_cursor_order==True and the display value is being edited, keep the decimal order of the cursor position after change.

set_value(value, notify_value_change=True, interrupt_edit=False, preserve_cursor_order=True)[source]

Set and display current numerical value.

If notify_value_change==True, emit the value_changed signal; otherwise, change value silently. If interrupt_edit==False and the edit is currently being modified by the user, don’t update the display (but still update the internally stored value). If preserve_cursor_order==True and the display value is being edited, keep the decimal order of the cursor position after change.

pylablib.core.gui.widgets.label module

class pylablib.core.gui.widgets.label.TextLabel(parent, value=None)[source]

Bases: object

Labview-style text label.

The main difference from the standard QLabel is the changed event.

clicked = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
mousePressEvent(ev)[source]
value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>

Signal emitted when value is changed

get_value()[source]

Get current numerical value

set_value(value)[source]

Set and display current text value

class pylablib.core.gui.widgets.label.EnumLabel(parent, options, value=None, prep=None)[source]

Bases: object

Labview-style label for enumerated values.

Can automatically convert input enum values into corresponding text labels based on the options dictionary. Can also specify a function which takes a single value argument and converts into a enum value before checking options; useful for “fuzzy” options (e.g., when 0 and False mean the same thing)

clicked = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
mousePressEvent(ev)[source]
set_out_of_range(action='error')[source]

Set behavior when out-of-range value is applied.

Can be "error" (raise error), "text" (turn value into text and display it), or "ignore" (keep current value).

set_options(options, value=None, index=None)[source]

Set new set of options.

If index_values is not None, set these as the new index values; otherwise, index values are reset. If options is a dictionary, interpret it as a mapping {option: index_value}. If value is specified, set as the new values. If index is specified, use it as the index of a new value; if both value and index are specified, the value takes priority.

value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>

Signal emitted when value is changed

get_value()[source]

Get current numerical value

set_value(value)[source]

Set and display current text value

repr_value(value)[source]

Return representation of value as a combo box text

class pylablib.core.gui.widgets.label.NumLabel(parent, value=None, limiter=None, formatter=None, allow_text=True)[source]

Bases: object

Labview-style numerical label.

Supports different number representations and metric prefixes.

Parameters:
  • parent – parent widget

  • value – initial value (None means no value is set)

  • limiter – number limiter (for details, see set_limiter())

  • formatter – number formatter (for details, see set_formatter())

  • allow_text – if True, can also take text values (which are displayed as is); otherwise, raise an error.

clicked = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
mousePressEvent(ev)[source]
set_limiter(limiter, new_value=None)[source]

Change current numerical limiter.

Limiter can be a callable object which takes a single value and either returns a limited value, or raises limiter.LimitError if it should be ignored; or it can be a tuple (lower, upper, action, value_type), where lower and upper are the limits (None means no limits), action defines out-of-limit action (either "ignore" to ignore entered value, or "coerce" to truncate to the nearest limit), and value_type can be None (keep value as is), "float" (cast value to float), "int" (cast value to int). If the tuple is shorter, the missing parts are filled by default values (None, None, "ignore", None).

set_formatter(formatter)[source]

Change current numerical formatter.

Formatter can be a callable object turning value into a string, a string ("float", "int", or a format string, e.g., ".5f"), or a tuple starting with "float" which contains arguments to the formatter.FloatFormatter.

set_float_formatter(output_format='auto', digits=9, add_trailing_zeros=True, leading_zeros=0, explicit_sign=False)[source]

Set up float formatter.

Has the same functionality as set_formatter() (i.e., set_float_formatter(*args) is equivalent to set_formatter(("float",)+args)), but explicitly lists the arguments.

Parameters:
  • output_format (str) – can be "auto" (use standard Python conversion), "SI" (use SI prefixes if possible), or "sci" (scientific “E” notation).

  • digits (int) – if add_trailing_zeros==False, determines the number of significant digits; otherwise, determines precision (number of digits after decimal point).

  • add_trailing_zeros (bool) – if True, always show fixed number of digits after the decimal point, with zero padding if necessary.

  • leading_zeros (bool) – determines the minimal size of the integer part (before the decimal point) of the number; pads with zeros if necessary.

  • explicit_sign (bool) – if True, always add explicit plus sign.

repr_value(value)[source]

Return representation of value according to the current numerical format

value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>

Signal emitted when value is changed

get_value()[source]

Get current numerical value

set_value(value)[source]

Set and display current numerical value

pylablib.core.gui.widgets.layout_manager module

class pylablib.core.gui.widgets.layout_manager.IQLayoutManagedWidget(*args, **kwargs)[source]

Bases: object

GUI widget which can manage layouts.

Typically, first it is set up using setup() method to specify the master layout kind; afterwards, widgets and sublayout can be added using add_to_layout(). In addition, it can directly add named sublayouts using add_sublayout() method.

Abstract mix-in class, which needs to be added to a class inheriting from QWidget. Alternatively, one can directly use QLayoutManagedWidget, which already inherits from QWidget.

setup(layout='grid', no_margins=False)[source]

Setup the layout.

Parameters:
  • layout – layout kind; can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

  • no_margins – if True, set all layout margins to zero (useful when the widget is in the middle of layout hierarchy)

using_layout(name)[source]

Use a different sublayout as default inside the with block

add_to_layout(element, location=None, kind='widget')[source]

Add an existing element to the layout at the given location.

kind can be "widget" for widgets, "layout" for other layouts, or "item" for layout items (spacers).

remove_layout_element(element)[source]

Remove a previously added layout element

get_element_position(element)[source]

Get the sublayout and the position of the given widget.

Return tuple (sublayout, location), where sublayout is the sublayout name ("name" for the main layout), and location is a tuple (row, column, rowspan, colspan). If the given widget is not in this layout, return None.

add_sublayout(name, kind='grid', location=None)[source]

Add a sublayout to the given location.

name specifies the sublayout name, which can be used to refer to it in specifying locations later. kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

using_new_sublayout(name, kind='grid', location=None)[source]

Create a different sublayout and use it as default inside the with block.

kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

get_sublayout(name=None)[source]

Get the previously added sublayout

iter_sublayout_items(name=None, include=('widget',), nested=False)[source]

Iterate over items contained in a given sublayout.

include is a tuple which contains items to iterate over; can include "widget" or "layout". If nested==True, iterate over items in contained layouts as well.

get_sublayout_kind(name=None)[source]

Get the kind of the previously added sublayout

get_layout_shape(name=None)[source]

Get shape (rows, cols) of the current layout

add_spacer(height=0, width=0, stretch_height=False, stretch_width=False, stretch=0, location='next')[source]

Add a spacer with the given width and height to the given location.

If stretch_height==True or stretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); if kind==”both”`, it can also be a tuple with two stretches along vertical and horizontal directions.

add_padding(kind='auto', location='next', stretch=0)[source]

Add a padding (expandable spacer) of the given kind to the given location.

kind can be "vertical", "horizontal", "auto" (vertical for grid and vbox layouts, horizontal for hbox), or "both" (stretches in both directions). If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); can also be a tuple with two stretches along vertical and horizontal directions.

set_row_stretch(*args, layout=None)[source]

Set row stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all rows.

set_column_stretch(*args, layout=None)[source]

Set column stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all columns.

add_decoration_label(text, location='next')[source]

Add a decoration text label with the given text

insert_row(row, sublayout=None, stretch=0)[source]

Insert a new row at the given location in the grid layout

insert_column(col, sublayout=None, stretch=0)[source]

Insert a new column at the given location in the grid layout

clear()[source]

Clear the layout and remove all the added elements

class pylablib.core.gui.widgets.layout_manager.QLayoutManagedWidget(*args, **kwargs)[source]

Bases: IQLayoutManagedWidget, object

GUI widget which can manage layouts.

Typically, first it is set up using setup() method to specify the master layout kind; afterwards, widgets and sublayout can be added using add_to_layout(). In addition, it can directly add named sublayouts using add_sublayout() method.

Simply a combination of IQLayoutManagedWidget and QWidget.

add_decoration_label(text, location='next')

Add a decoration text label with the given text

add_padding(kind='auto', location='next', stretch=0)

Add a padding (expandable spacer) of the given kind to the given location.

kind can be "vertical", "horizontal", "auto" (vertical for grid and vbox layouts, horizontal for hbox), or "both" (stretches in both directions). If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); can also be a tuple with two stretches along vertical and horizontal directions.

add_spacer(height=0, width=0, stretch_height=False, stretch_width=False, stretch=0, location='next')

Add a spacer with the given width and height to the given location.

If stretch_height==True or stretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); if kind==”both”`, it can also be a tuple with two stretches along vertical and horizontal directions.

add_sublayout(name, kind='grid', location=None)

Add a sublayout to the given location.

name specifies the sublayout name, which can be used to refer to it in specifying locations later. kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

add_to_layout(element, location=None, kind='widget')

Add an existing element to the layout at the given location.

kind can be "widget" for widgets, "layout" for other layouts, or "item" for layout items (spacers).

clear()

Clear the layout and remove all the added elements

get_element_position(element)

Get the sublayout and the position of the given widget.

Return tuple (sublayout, location), where sublayout is the sublayout name ("name" for the main layout), and location is a tuple (row, column, rowspan, colspan). If the given widget is not in this layout, return None.

get_layout_shape(name=None)

Get shape (rows, cols) of the current layout

get_sublayout(name=None)

Get the previously added sublayout

get_sublayout_kind(name=None)

Get the kind of the previously added sublayout

insert_column(col, sublayout=None, stretch=0)

Insert a new column at the given location in the grid layout

insert_row(row, sublayout=None, stretch=0)

Insert a new row at the given location in the grid layout

iter_sublayout_items(name=None, include=('widget',), nested=False)

Iterate over items contained in a given sublayout.

include is a tuple which contains items to iterate over; can include "widget" or "layout". If nested==True, iterate over items in contained layouts as well.

remove_layout_element(element)

Remove a previously added layout element

set_column_stretch(*args, layout=None)

Set column stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all columns.

set_row_stretch(*args, layout=None)

Set row stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all rows.

setup(layout='grid', no_margins=False)

Setup the layout.

Parameters:
  • layout – layout kind; can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

  • no_margins – if True, set all layout margins to zero (useful when the widget is in the middle of layout hierarchy)

using_layout(name)

Use a different sublayout as default inside the with block

using_new_sublayout(name, kind='grid', location=None)

Create a different sublayout and use it as default inside the with block.

kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

pylablib.core.gui.widgets.param_table module

class pylablib.core.gui.widgets.param_table.ParamTable(parent=None, name=None)[source]

Bases: QWidgetContainer

GUI parameter table.

Simplifies creating code-generated controls and displays table layouts.

Has methods for adding various kinds of controls (labels, edit boxes, combo boxes, check boxes), automatically creates values table for easy settings/getting. By default supports 2-column (label-control) and 3-column (label-control-indicator) layout, depending on the parameters given to setup().

Similar to GUIValues, has three container-like accessor: .h for getting the value handler (i.e., self.get_handler(name) is equivalent to self.h[name]), .w for getting the underlying widget (i.e., self.get_widget(name) is equivalent to self.w[name]), .v for settings/getting values using the default getting method (equivalent to .wv if cache_values=False in setup(), and to .cv otherwise), .wv for settings/getting current current widget values without caching (i.e., self.get_value(name) is equivalent to self.v[name], and self.set_value(name, value) is equivalent to self.v[name]=value), .cv for settings/getting values using cached value’s table for getting (i.e., self.current_values[name] is equivalent to self.cv[name], and self.set_value(name, value) is equivalent to self.cv[name]=value), (i.e., self.get_value(name) is equivalent to self.v[name], and self.set_value(name, value) is equivalent to self.v[name]=value), .i for settings/getting indicator values (i.e., self.get_indicator(name) is equivalent to self.i[name], and self.set_indicator(name, value) is equivalent to self.i[name]=value) .vs for getting the value changed Qt signal (i.e., self.get_value_changed_signal(name) is equivalent to self.s[name]),

Like most widgets, requires calling setup() to set up before usage.

Parameters:

parent – parent widget

setup(name=None, add_indicator=True, gui_thread_safe=False, cache_values=False, change_focused_control=False)[source]

Setup the table.

Parameters:
  • name (str) – table widget name

  • add_indicator (bool) – if True, add indicators for all added widgets by default.

  • gui_thread_safe (bool) – if True, all value-access and indicator-access calls (get/set_value, get/set_all_values, get/set_indicator, and update_indicators) are automatically called in the GUI thread.

  • cache_values (bool) – if True or "update_one", store a dictionary with all the current values and update it every time a GUI value is changed; provides a thread-safe way to check current parameters without lag (unlike get_value() or get_all_values() with gui_thread_safe==True, which re-route calls to a GUI thread and may cause up to 100ms delay) can also be set to "update_all", in which case change of any value will cause value update of all variables; otherwise, change of a value will only cause update of that same value (might potentially miss some value updates for custom controls).

  • change_focused_control (bool) – if False and set_value() method is called while the widget has user focus, ignore the value; note that set_all_values() will still set the widget value.

add_sublayout(name, kind='grid', location=('next', 0, 1, 'end'))[source]

Add a sublayout to the given location.

name specifies the sublayout name, which can be used to refer to it in specifying locations later. kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

using_new_sublayout(name, kind='grid', location=('next', 0, 1, 'end'))[source]

Create a different sublayout and use it as default inside the with block.

kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

pad_borders(kind='both', stretch=0)[source]

Add expandable paddings on the bottom and/or right border.

kind can be "bottom", "right", "both", or "none" (do nothing). Note that if more elements are added, they will be placed after the padding, so the table will be padded in the middle.

add_frame(name, layout='vbox', location=('next', 0, 1, 'end'), gui_values_path=True, no_margins=True)[source]

Add a new frame container to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

add_group_box(name, caption, layout='vbox', location=('next', 0, 1, 'end'), gui_values_path=True, no_margins=True)[source]

Add a new group box container with the given caption to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

class ParamRow(widget, label, indicator, value_handler, indicator_handler)

Bases: tuple

indicator
indicator_handler
label
value_handler
widget
add_simple_widget(name, widget, label=None, value_handler=None, add_indicator=None, location=None, tooltip=None, add_change_event=True)[source]

Add a ‘simple’ (single-spaced, single-valued) widget to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • widget – widget to add

  • label (str) – if not None, specifies label to put in front of the widget in the layout

  • value_handler – value handler of the widget; by default, use auto-detected value handler (works for many simple built-in or custom widgets)

  • add_indicator – if True, add an indicator label in the third column and a corresponding indicator handler in the built-in values table; by default, use the default value supplied to setup()

  • location (tuple) – tuple (row, column) specifying location of the widget (or widget label, if it is specified); by default, add to a new row in the end and into the first column can also be a string "skip", which means that the widget is added to some other location manually later (this option only works if label=None, and doesn’t add any indicator)

  • tooltip – widget tooltip (mouseover text)

  • add_change_event (bool) – if True, changing of the widget’s value emits the table’s contained_value_changed event

Return the widget’s value handler

add_custom_widget(name, widget, value_handler=None, indicator_handler=None, location=None, tooltip=None, add_change_event=True)[source]

Add a ‘custom’ (multi-spaced, possibly complex-valued) widget to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • widget – widget to add

  • value_handler – value handler of the widget; by default, use auto-detected value handler (works for many simple built-in or custom widgets)

  • indicator_handler – indicator handler of the widget; by default, use auto-detected indicator handler (use set/get_indicator methods if present, or no indicator otherwise)

  • location (tuple) – tuple (row, column, rowspan, colspan) specifying location of the widget; by default, add to a new row in the end and into the first column, span one row and all table columns can also be a string "skip", which means that the widget is added to some other location manually later

  • add_change_event (bool) – if True, changing of the widget’s value emits the table’s contained_value_changed event

Return the widget’s value handler

remove_widget(name)[source]

Remove the widget and, if applicable, its indicator and label

add_virtual_element(name, value=None, multivalued=False, add_indicator=None)[source]

Add a virtual table element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view (its value can be set or read, it has on-change events, it can have indicator). The element value is simply stored on set and retrieved on get. If multivalued==True, the internal value is assumed to be complex, so it is forced to be a Dictionary every time it is set. If add_indicator==True, add default indicator handler as well.

add_property_element(name, getter=None, setter=None, add_indicator=True)[source]

Add a property value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view; each time the value is set or get, the corresponding setter and getter methods are called. If add_indicator==True, add default (stored value) indicator handler as well.

add_button(name, caption, label=None, add_indicator=None, location=None, tooltip=None, add_change_event=True, virtual=False)[source]

Add a button to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • caption (str) – text on the button

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_toggle_button(name, caption, value=False, label=None, add_indicator=None, location=None, tooltip=None, add_change_event=True, virtual=False)[source]

Add a toggle button to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • caption (str or list) – text on the button; can be a single string, or a list of two strings which specifies the caption for off and on states

  • value (bool) – specifies initial value

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_dropdown_button(name, caption, options=None, index_values=None, label=None, add_indicator=None, location=None, tooltip=None, add_change_event=True, virtual=False)[source]

Add a button which shows a dropdown menu when clicked.

Similar in behavior to a regular button, but its changed event provides a single argument which is the name of the selected item.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • caption (str or list) – text on the button

  • options (list) – list of strings specifying menu options

  • index_values (list) – list of values corresponding to menu options; if supplied, these values are used when setting/getting values or sending signals.

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_check_box(name, caption, value=False, label=None, add_indicator=None, location=None, tooltip=None, add_change_event=True, virtual=False)[source]

Add a checkbox to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • caption (str) – text on the checkbox

  • value (bool) – specifies initial value

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_text_label(name, value='', label=None, location=None, tooltip=None, add_change_event=False, virtual=False)[source]

Add a text label to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • value (bool) – specifies initial value

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_enum_label(name, options, value=None, out_of_range='error', prep=None, label=None, location=None, tooltip=None, add_change_event=False, virtual=False)[source]

Add a text label to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • options (list) – dictionary {index_value: text} which converts values into text

  • out_of_range (str) – behavior when out-of-range value is applied; can be "error" (raise error), "text" (convert value into text), or "ignore" (keep current value).

  • prep – a function which takes a single value argument and converts into an option; useful for “fuzzy” options (e.g., when 0 and False mean the same thing)

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_num_label(name, value=0, limiter=None, formatter=None, label=None, tooltip=None, location=None, add_change_event=False, virtual=False)[source]

Add a numerical label to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • value (float) – specifies initial value

  • limiter (tuple) – tuple (upper_limit, lower_limit, action, value_type) specifying value limits; see limiter.as_limiter() for details

  • formatter (tuple) – either "int" (for integer values), or tuple specifying floating value format; see formatter.as_formatter() for details

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_text_edit(name, value='', label=None, multiline=False, add_indicator=None, location=None, tooltip=None, add_change_event=True, virtual=False)[source]

Add a text edit to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • value (bool) – specifies initial value

  • multiline (bool) – if True, use multi-line text edit widget; otherwise, use a standard single-line edit

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_num_edit(name, value=None, limiter=None, formatter=None, custom_steps=None, label=None, add_indicator=None, location=None, tooltip=None, add_change_event=True, virtual=False)[source]

Add a numerical edit to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • value (bool) – specifies initial value

  • limiter (tuple) – tuple (upper_limit, lower_limit, action, value_type) specifying value limits; see NumEdit.set_limiter() for details

  • formatter (tuple) – either "int" (for integer values), or tuple specifying floating value format; see NumEdit.set_formatter() for details

  • custom_steps – if not None, can specify custom fixed value steps when up/down keys are pressed with a modifier key (Control, Alt, or Shift) specifies a dictionary {'ctrl':ctrl_step, 'alt':alt_step, 'shift':shift_step} with the corresponding steps (missing elements mean that the modifier key is ignored)

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_progress_bar(name, value=None, label=None, location=None, tooltip=None, add_change_event=True, virtual=False)[source]

Add a progress bar to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • value (bool) – specifies initial value

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_combo_box(name, value=None, options=None, index_values=None, out_of_range='reset', label=None, add_indicator=None, location=None, tooltip=None, add_change_event=True, virtual=False)[source]

Add a combo box to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • value – specifies initial value

  • options (list) – list of strings specifying box options or a dictionary {option: index_value}

  • index_values (list) – list of values corresponding to box options; if supplied, these values are used when setting/getting values or sending signals; if options is a dictionary, this parameter is ignored

  • out_of_range (str) – behavior when out-of-range value is applied; can be "error" (raise error), "reset" (reset to no-value position), or "ignore" (keep current value).

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

set_enabled(names=None, enabled=True, include_indicator=True, include_label=True)[source]

Enable or disable widgets with the given names (by default, all widgets)

set_visible(names=None, visible=True, include_indicator=True, include_label=True)[source]

Show or hide widgets with the given names (by default, all widgets)

get_value(name=None)

Get value of a widget with the given name (None means all values)

get_all_values()

Get values of all widget in the container

set_value(name, value, force=True)

Set value of a widget with the given name.

If force==True, force widget value (e.g., ignoring restriction on not changing values of focused widgets)

set_all_values(value, force=True)

Set values of all widgets in the table.

If force==True, force widget value (e.g., ignoring restriction on not changing values of focused widgets)

update_value(name=None)

Send update signal for a handler with a given name or list of names.

Emit a value changed signal with the current value to notify the subscribed slots. If name is None, emit for all values in the table.

get_widget(name)[source]

Get a widget corresponding to a value with the given name

get_indicator_widget(name)[source]

Get indicator widget for a parameter with the given name, or None if this parameter has no indicator label

get_label_widget(name)[source]

Get label widget for a parameter with the given name, or None if this parameter has no label

get_child(name)[source]

Get the child widget with the given name

remove_child(name, clear=True)[source]

Remove widget from the container and the layout and (if clear==True) clear it, and remove it

get_indicator(name=None)

Get indicator value for a widget with the given name (None means all indicators)

get_all_indicators()

Get indicator values of all widget in the container

set_indicator(name, value, ignore_missing=False)

Set indicator value for a widget or a branch with the given name

set_all_indicators(value, ignore_missing=True)
update_indicators()

Update all indicators to represent current values

clear(disconnect=False)[source]

Clear the table (remove all widgets)

If disconnect==True, also disconnect all slots connected to the contained_value_changed signal.

TimerUIDGenerator = <pylablib.core.utils.general.NamedUIDGenerator object>
add_child(name, widget, location=None, gui_values_path=True)

Add a contained child widget.

name specifies the child storage name; if name==False, only add the widget to they layout, but not to the container. location specifies the layout location to which the widget is added; if location=="skip", skip adding it to the layout (can be manually added later). Note that if the widget is added to the layout, it will be completely deleted when clear or remove_child methods are called; otherwise, simply its clear method will be called, and its GUI values will be deleted.

If gui_values_path is False or None, do not add it to the GUI values table; if it is True, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise, gui_values_path specifies the path under which the widget values are stored.

add_child_values(name, widget, path, add_change_event=True)

Add child’s values to the container’s table.

If widget is a container and path=="" or ends in "/*" (e.g., "subpath/*"), use its setup_gui_values to make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_decoration_label(text, location='next')

Add a decoration text label with the given text

add_padding(kind='auto', location='next', stretch=0)

Add a padding (expandable spacer) of the given kind to the given location.

kind can be "vertical", "horizontal", "auto" (vertical for grid and vbox layouts, horizontal for hbox), or "both" (stretches in both directions). If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); can also be a tuple with two stretches along vertical and horizontal directions.

add_spacer(height=0, width=0, stretch_height=False, stretch_width=False, stretch=0, location='next')

Add a spacer with the given width and height to the given location.

If stretch_height==True or stretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); if kind==”both”`, it can also be a tuple with two stretches along vertical and horizontal directions.

add_timer(name, period, autostart=True)

Add a periodic timer with the given name and period.

Rarely needs to be called explicitly (one is created automatically if timer event is created). If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_timer_event(name, loop=None, start=None, stop=None, period=None, timer=None, autostart=True)

Add timer event with the given name.

Add an event which should be called periodically (e.g., a GUI update). Internally implemented through Qt timers. loop, start and stop are the functions called, correspondingly, on timer (periodically), when timer is start, and when it’s finished. One can either specify the timer by name (timer parameter), or create a new one with the given period. If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_to_layout(element, location=None, kind='widget')

Add an existing element to the layout at the given location.

kind can be "widget" for widgets, "layout" for other layouts, or "item" for layout items (spacers).

contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
get_element_position(element)

Get the sublayout and the position of the given widget.

Return tuple (sublayout, location), where sublayout is the sublayout name ("name" for the main layout), and location is a tuple (row, column, rowspan, colspan). If the given widget is not in this layout, return None.

get_handler(name)

Get value handler of a widget with the given name

get_layout_shape(name=None)

Get shape (rows, cols) of the current layout

get_sublayout(name=None)

Get the previously added sublayout

get_sublayout_kind(name=None)

Get the kind of the previously added sublayout

get_value_changed_signal(name)

Get a value-changed signal for a widget with the given name

insert_column(col, sublayout=None, stretch=0)

Insert a new column at the given location in the grid layout

insert_row(row, sublayout=None, stretch=0)

Insert a new row at the given location in the grid layout

is_running()

Check if the container is running (started and not yet stopped)

is_stopping()

Check if the container is stopping (stopping initialized and not yet done)

is_timer_running(name)

Check if the timer with the given name is running

iter_sublayout_items(name=None, include=('widget',), nested=False)

Iterate over items contained in a given sublayout.

include is a tuple which contains items to iterate over; can include "widget" or "layout". If nested==True, iterate over items in contained layouts as well.

remove_layout_element(element)

Remove a previously added layout element

set_column_stretch(*args, layout=None)

Set column stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all columns.

set_row_stretch(*args, layout=None)

Set row stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all rows.

setup_name(name)

Set the object’s name

start()

Start the container.

Starts all the internal timers, and calls start method for all the contained widgets.

start_timer(name)

Start the timer with the given name (also called automatically on start() method)

stop()

Stop the container.

Stops all the internal timers, and calls stop method for all the contained widgets.

stop_timer(name)

Stop the timer with the given name (also called automatically on stop() method)

using_layout(name)

Use a different sublayout as default inside the with block

class pylablib.core.gui.widgets.param_table.StatusTable(parent=None, name=None)[source]

Bases: ParamTable

Expansion of ParamTable which adds status lines, which automatically subscribe to signals and update values.

setup(name=None, add_indicator=True, gui_thread_safe=False, cache_values=False, change_focused_control=False)[source]

Setup the table.

Parameters:
  • name (str) – table widget name

  • add_indicator (bool) – if True, add indicators for all added widgets by default.

  • gui_thread_safe (bool) – if True, all value-access and indicator-access calls (get/set_value, get/set_all_values, get/set_indicator, and update_indicators) are automatically called in the GUI thread.

  • cache_values (bool) – if True or "update_one", store a dictionary with all the current values and update it every time a GUI value is changed; provides a thread-safe way to check current parameters without lag (unlike get_value() or get_all_values() with gui_thread_safe==True, which re-route calls to a GUI thread and may cause up to 100ms delay) can also be set to "update_all", in which case change of any value will cause value update of all variables; otherwise, change of a value will only cause update of that same value (might potentially miss some value updates for custom controls).

  • change_focused_control (bool) – if False and set_value() method is called while the widget has user focus, ignore the value; note that set_all_values() will still set the widget value.

add_status_line(name, label=None, srcs=None, tags=None, filt=None, fmt=None)[source]

Add a status line to the table:

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • label (str) – if not None, specifies label to put in front of the status line

  • srcs (list) – status signal sources

  • tags (list) – status signal tags

  • filt (list) – filter function for the signals

  • fmt – if not None, specifies a function which takes 3 arguments (signal source, tag, and value) and generates a status line text.

update_status_line(name, thread=None, path=None)[source]

Update status line to the variable with the given path from the thread with the given thread name.

If thread is None, use srcs name provided upon creation. If path is None, use tags name provided upon creation.

TimerUIDGenerator = <pylablib.core.utils.general.NamedUIDGenerator object>
add_button(name, caption, label=None, add_indicator=None, location=None, tooltip=None, add_change_event=True, virtual=False)

Add a button to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • caption (str) – text on the button

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_check_box(name, caption, value=False, label=None, add_indicator=None, location=None, tooltip=None, add_change_event=True, virtual=False)

Add a checkbox to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • caption (str) – text on the checkbox

  • value (bool) – specifies initial value

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_child(name, widget, location=None, gui_values_path=True)

Add a contained child widget.

name specifies the child storage name; if name==False, only add the widget to they layout, but not to the container. location specifies the layout location to which the widget is added; if location=="skip", skip adding it to the layout (can be manually added later). Note that if the widget is added to the layout, it will be completely deleted when clear or remove_child methods are called; otherwise, simply its clear method will be called, and its GUI values will be deleted.

If gui_values_path is False or None, do not add it to the GUI values table; if it is True, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise, gui_values_path specifies the path under which the widget values are stored.

add_child_values(name, widget, path, add_change_event=True)

Add child’s values to the container’s table.

If widget is a container and path=="" or ends in "/*" (e.g., "subpath/*"), use its setup_gui_values to make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. if add_change_event==True, changing of the widget’s value emits the container’s contained_value_changed event

add_combo_box(name, value=None, options=None, index_values=None, out_of_range='reset', label=None, add_indicator=None, location=None, tooltip=None, add_change_event=True, virtual=False)

Add a combo box to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • value – specifies initial value

  • options (list) – list of strings specifying box options or a dictionary {option: index_value}

  • index_values (list) – list of values corresponding to box options; if supplied, these values are used when setting/getting values or sending signals; if options is a dictionary, this parameter is ignored

  • out_of_range (str) – behavior when out-of-range value is applied; can be "error" (raise error), "reset" (reset to no-value position), or "ignore" (keep current value).

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_custom_widget(name, widget, value_handler=None, indicator_handler=None, location=None, tooltip=None, add_change_event=True)

Add a ‘custom’ (multi-spaced, possibly complex-valued) widget to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • widget – widget to add

  • value_handler – value handler of the widget; by default, use auto-detected value handler (works for many simple built-in or custom widgets)

  • indicator_handler – indicator handler of the widget; by default, use auto-detected indicator handler (use set/get_indicator methods if present, or no indicator otherwise)

  • location (tuple) – tuple (row, column, rowspan, colspan) specifying location of the widget; by default, add to a new row in the end and into the first column, span one row and all table columns can also be a string "skip", which means that the widget is added to some other location manually later

  • add_change_event (bool) – if True, changing of the widget’s value emits the table’s contained_value_changed event

Return the widget’s value handler

add_decoration_label(text, location='next')

Add a decoration text label with the given text

add_dropdown_button(name, caption, options=None, index_values=None, label=None, add_indicator=None, location=None, tooltip=None, add_change_event=True, virtual=False)

Add a button which shows a dropdown menu when clicked.

Similar in behavior to a regular button, but its changed event provides a single argument which is the name of the selected item.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • caption (str or list) – text on the button

  • options (list) – list of strings specifying menu options

  • index_values (list) – list of values corresponding to menu options; if supplied, these values are used when setting/getting values or sending signals.

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_enum_label(name, options, value=None, out_of_range='error', prep=None, label=None, location=None, tooltip=None, add_change_event=False, virtual=False)

Add a text label to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • options (list) – dictionary {index_value: text} which converts values into text

  • out_of_range (str) – behavior when out-of-range value is applied; can be "error" (raise error), "text" (convert value into text), or "ignore" (keep current value).

  • prep – a function which takes a single value argument and converts into an option; useful for “fuzzy” options (e.g., when 0 and False mean the same thing)

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_frame(name, layout='vbox', location=('next', 0, 1, 'end'), gui_values_path=True, no_margins=True)

Add a new frame container to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

add_group_box(name, caption, layout='vbox', location=('next', 0, 1, 'end'), gui_values_path=True, no_margins=True)

Add a new group box container with the given caption to the layout.

layout specifies the layout ("vbox", "hbox", or "grid") of the new frame, and location specifies its location within the container layout. If no_margins==True, the frame will have no inner layout margins. The other parameters are the same as in add_child() method.

add_num_edit(name, value=None, limiter=None, formatter=None, custom_steps=None, label=None, add_indicator=None, location=None, tooltip=None, add_change_event=True, virtual=False)

Add a numerical edit to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • value (bool) – specifies initial value

  • limiter (tuple) – tuple (upper_limit, lower_limit, action, value_type) specifying value limits; see NumEdit.set_limiter() for details

  • formatter (tuple) – either "int" (for integer values), or tuple specifying floating value format; see NumEdit.set_formatter() for details

  • custom_steps – if not None, can specify custom fixed value steps when up/down keys are pressed with a modifier key (Control, Alt, or Shift) specifies a dictionary {'ctrl':ctrl_step, 'alt':alt_step, 'shift':shift_step} with the corresponding steps (missing elements mean that the modifier key is ignored)

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_num_label(name, value=0, limiter=None, formatter=None, label=None, tooltip=None, location=None, add_change_event=False, virtual=False)

Add a numerical label to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • value (float) – specifies initial value

  • limiter (tuple) – tuple (upper_limit, lower_limit, action, value_type) specifying value limits; see limiter.as_limiter() for details

  • formatter (tuple) – either "int" (for integer values), or tuple specifying floating value format; see formatter.as_formatter() for details

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_padding(kind='auto', location='next', stretch=0)

Add a padding (expandable spacer) of the given kind to the given location.

kind can be "vertical", "horizontal", "auto" (vertical for grid and vbox layouts, horizontal for hbox), or "both" (stretches in both directions). If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); can also be a tuple with two stretches along vertical and horizontal directions.

add_progress_bar(name, value=None, label=None, location=None, tooltip=None, add_change_event=True, virtual=False)

Add a progress bar to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • value (bool) – specifies initial value

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_property_element(name, getter=None, setter=None, add_indicator=True)

Add a property value element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view; each time the value is set or get, the corresponding setter and getter methods are called. If add_indicator==True, add default (stored value) indicator handler as well.

add_simple_widget(name, widget, label=None, value_handler=None, add_indicator=None, location=None, tooltip=None, add_change_event=True)

Add a ‘simple’ (single-spaced, single-valued) widget to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • widget – widget to add

  • label (str) – if not None, specifies label to put in front of the widget in the layout

  • value_handler – value handler of the widget; by default, use auto-detected value handler (works for many simple built-in or custom widgets)

  • add_indicator – if True, add an indicator label in the third column and a corresponding indicator handler in the built-in values table; by default, use the default value supplied to setup()

  • location (tuple) – tuple (row, column) specifying location of the widget (or widget label, if it is specified); by default, add to a new row in the end and into the first column can also be a string "skip", which means that the widget is added to some other location manually later (this option only works if label=None, and doesn’t add any indicator)

  • tooltip – widget tooltip (mouseover text)

  • add_change_event (bool) – if True, changing of the widget’s value emits the table’s contained_value_changed event

Return the widget’s value handler

add_spacer(height=0, width=0, stretch_height=False, stretch_width=False, stretch=0, location='next')

Add a spacer with the given width and height to the given location.

If stretch_height==True or stretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is not None, it specifies stretch of the spacer the corresponding direction (applied to the upper row and leftmost column for multi-cell spacer); if kind==”both”`, it can also be a tuple with two stretches along vertical and horizontal directions.

add_sublayout(name, kind='grid', location=('next', 0, 1, 'end'))

Add a sublayout to the given location.

name specifies the sublayout name, which can be used to refer to it in specifying locations later. kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

add_text_edit(name, value='', label=None, multiline=False, add_indicator=None, location=None, tooltip=None, add_change_event=True, virtual=False)

Add a text edit to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • value (bool) – specifies initial value

  • multiline (bool) – if True, use multi-line text edit widget; otherwise, use a standard single-line edit

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_text_label(name, value='', label=None, location=None, tooltip=None, add_change_event=False, virtual=False)

Add a text label to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • value (bool) – specifies initial value

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_timer(name, period, autostart=True)

Add a periodic timer with the given name and period.

Rarely needs to be called explicitly (one is created automatically if timer event is created). If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_timer_event(name, loop=None, start=None, stop=None, period=None, timer=None, autostart=True)

Add timer event with the given name.

Add an event which should be called periodically (e.g., a GUI update). Internally implemented through Qt timers. loop, start and stop are the functions called, correspondingly, on timer (periodically), when timer is start, and when it’s finished. One can either specify the timer by name (timer parameter), or create a new one with the given period. If autostart==True and the container has been started (by calling start() method), start the timer as well.

add_to_layout(element, location=None, kind='widget')

Add an existing element to the layout at the given location.

kind can be "widget" for widgets, "layout" for other layouts, or "item" for layout items (spacers).

add_toggle_button(name, caption, value=False, label=None, add_indicator=None, location=None, tooltip=None, add_change_event=True, virtual=False)

Add a toggle button to the table.

Parameters:
  • name (str) – widget name (used to reference its value in the values table)

  • caption (str or list) – text on the button; can be a single string, or a list of two strings which specifies the caption for off and on states

  • value (bool) – specifies initial value

  • virtual (bool) – if True, the widget is not added, and a virtual handler is added instead

Rest of the arguments and the return value are the same as add_simple_widget().

add_virtual_element(name, value=None, multivalued=False, add_indicator=None)

Add a virtual table element.

Doesn’t correspond to any actual widget, but behaves very similarly from the application point of view (its value can be set or read, it has on-change events, it can have indicator). The element value is simply stored on set and retrieved on get. If multivalued==True, the internal value is assumed to be complex, so it is forced to be a Dictionary every time it is set. If add_indicator==True, add default indicator handler as well.

clear(disconnect=False)

Clear the table (remove all widgets)

If disconnect==True, also disconnect all slots connected to the contained_value_changed signal.

contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='139946557760272'>
get_all_indicators()

Get indicator values of all widget in the container

get_all_values()

Get values of all widget in the container

get_child(name)

Get the child widget with the given name

get_element_position(element)

Get the sublayout and the position of the given widget.

Return tuple (sublayout, location), where sublayout is the sublayout name ("name" for the main layout), and location is a tuple (row, column, rowspan, colspan). If the given widget is not in this layout, return None.

get_handler(name)

Get value handler of a widget with the given name

get_indicator(name=None)

Get indicator value for a widget with the given name (None means all indicators)

get_indicator_widget(name)

Get indicator widget for a parameter with the given name, or None if this parameter has no indicator label

get_label_widget(name)

Get label widget for a parameter with the given name, or None if this parameter has no label

get_layout_shape(name=None)

Get shape (rows, cols) of the current layout

get_sublayout(name=None)

Get the previously added sublayout

get_sublayout_kind(name=None)

Get the kind of the previously added sublayout

get_value(name=None)

Get value of a widget with the given name (None means all values)

get_value_changed_signal(name)

Get a value-changed signal for a widget with the given name

get_widget(name)

Get a widget corresponding to a value with the given name

insert_column(col, sublayout=None, stretch=0)

Insert a new column at the given location in the grid layout

insert_row(row, sublayout=None, stretch=0)

Insert a new row at the given location in the grid layout

is_running()

Check if the container is running (started and not yet stopped)

is_stopping()

Check if the container is stopping (stopping initialized and not yet done)

is_timer_running(name)

Check if the timer with the given name is running

iter_sublayout_items(name=None, include=('widget',), nested=False)

Iterate over items contained in a given sublayout.

include is a tuple which contains items to iterate over; can include "widget" or "layout". If nested==True, iterate over items in contained layouts as well.

pad_borders(kind='both', stretch=0)

Add expandable paddings on the bottom and/or right border.

kind can be "bottom", "right", "both", or "none" (do nothing). Note that if more elements are added, they will be placed after the padding, so the table will be padded in the middle.

remove_child(name, clear=True)

Remove widget from the container and the layout and (if clear==True) clear it, and remove it

remove_layout_element(element)

Remove a previously added layout element

remove_widget(name)

Remove the widget and, if applicable, its indicator and label

set_all_indicators(value, ignore_missing=True)
set_all_values(value, force=True)

Set values of all widgets in the table.

If force==True, force widget value (e.g., ignoring restriction on not changing values of focused widgets)

set_column_stretch(*args, layout=None)

Set column stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all columns.

set_enabled(names=None, enabled=True, include_indicator=True, include_label=True)

Enable or disable widgets with the given names (by default, all widgets)

set_indicator(name, value, ignore_missing=False)

Set indicator value for a widget or a branch with the given name

set_row_stretch(*args, layout=None)

Set row stretch for a given layout.

Takes either two arguments index and stretch, or a single list of stretches for all rows.

set_value(name, value, force=True)

Set value of a widget with the given name.

If force==True, force widget value (e.g., ignoring restriction on not changing values of focused widgets)

set_visible(names=None, visible=True, include_indicator=True, include_label=True)

Show or hide widgets with the given names (by default, all widgets)

setup_name(name)

Set the object’s name

start()

Start the container.

Starts all the internal timers, and calls start method for all the contained widgets.

start_timer(name)

Start the timer with the given name (also called automatically on start() method)

stop()

Stop the container.

Stops all the internal timers, and calls stop method for all the contained widgets.

stop_timer(name)

Stop the timer with the given name (also called automatically on stop() method)

update_indicators()

Update all indicators to represent current values

update_value(name=None)

Send update signal for a handler with a given name or list of names.

Emit a value changed signal with the current value to notify the subscribed slots. If name is None, emit for all values in the table.

using_layout(name)

Use a different sublayout as default inside the with block

using_new_sublayout(name, kind='grid', location=('next', 0, 1, 'end'))

Create a different sublayout and use it as default inside the with block.

kind can be "grid", "vbox" (vertical single-column box), or "hbox" (horizontal single-row box).

Module contents