pylablib.core.gui.widgets package
Submodules
pylablib.core.gui.widgets.combo_box module
- class pylablib.core.gui.widgets.combo_box.ComboBox(parent)[source]
Bases:
objectExpanded combo box.
Maintains internally stored consistent value (which can be, e.g., accessed from different threads). Allows setting values which are reported via
value_changedsignal instead of simple indices.- 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).
- keep = keep
- none = none
- set_index_values(index_values, value=None, index=None, unselected_value=keep)[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., usingaddItemorinsertItemmethods), 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. If unselected_value is supplied, it specifies which value corresponds to no combo box value being selected (by default, keep the current value).
- set_options(options, index_values=None, value=None, index=None, unselected_value=keep)[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. If unselected_value is supplied, it specifies which value corresponds to no combo box value being selected (by default, keep the current value).
- 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='133174990151376'>
Signal emitted when value is changed
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:
objectBasic 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 useQContainer, which already inherits fromQObject.- TimerUIDGenerator = <pylablib.core.utils.general.NamedUIDGenerator object>
- contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
- setup(name=None)[source]
Setup the container by initializing its GUI values and setting the
ctlattribute
- 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==Trueand the container has been started (by callingstart()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)
- 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==Trueand the container has been started (by callingstart()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 itssetup_gui_valuesto make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- add_child(name, widget, gui_values_path=True, add_change_event=True)[source]
Add a contained child widget.
If gui_values_path is
FalseorNone, do not add it to the GUI values table; if it isTrue, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise,gui_values_pathspecifies the path under which the widget values are stored. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- 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 aDictionaryevery time it is set. Ifadd_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
startmethod for all the contained widgets.
- stop()
Stop the container.
Stops all the internal timers, and calls
stopmethod for all the contained widgets.
- clear()[source]
Clear the container.
Stop all timers and widgets, and call
clearmethods of all contained widgets, remove all widgets from the values table, remove all widgets from the table.
- 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 (
Nonemeans all indicators)
- class pylablib.core.gui.widgets.container.QContainer(*args, name=None, **kwargs)[source]
Bases:
IQContainer,objectBasic 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
IQContainerandQObject.- 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
FalseorNone, do not add it to the GUI values table; if it isTrue, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise,gui_values_pathspecifies the path under which the widget values are stored. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- 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 itssetup_gui_valuesto make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- 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==Trueand the container has been started (by callingstart()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==Trueand the container has been started (by callingstart()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 aDictionaryevery time it is set. Ifadd_indicator==True, add default indicator handler as well.
- clear()
Clear the container.
Stop all timers and widgets, and call
clearmethods 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='133174990151376'>
- 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 (
Nonemeans all indicators)
- get_value(name=None)
Get value of a widget with the given name (
Nonemeans 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 (
Nonemeans all values)
- setup(name=None)
Setup the container by initializing its GUI values and setting the
ctlattribute
- setup_name(name)
Set the object’s name
- start()
Start the container.
Starts all the internal timers, and calls
startmethod 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
stopmethod for all the contained widgets.
- 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,IQContainerGeneric widget container.
Combines
IQContainermanagement of GUI values and timers withIQLayoutManagedWidgetmanagement 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 specifyinglocation="skip"inadd_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 useQWidgetContainer, which already inherits fromQWidget.- 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; iflocation=="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 whenclearorremove_childmethods are called; otherwise, simply itsclearmethod will be called, and its GUI values will be deleted.If gui_values_path is
FalseorNone, do not add it to the GUI values table; if it isTrue, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise,gui_values_pathspecifies 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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_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 itssetup_gui_valuesto make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- add_decoration_label(text, location='next', tag=None)
Add a decoration text label with the given text
- add_padding(kind='auto', location='next', stretch=0, tag=None)
Add a padding (expandable spacer) of the given kind to the given location.
kind can be
"vertical","horizontal","auto"(vertical forgridandvboxlayouts, horizontal forhbox), or"both"(stretches in both directions). If stretch is notNone, 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', tag=None)
Add a spacer with the given width and height to the given location.
If
stretch_height==Trueorstretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is notNone, 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==Trueand the container has been started (by callingstart()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==Trueand the container has been started (by callingstart()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 aDictionaryevery time it is set. Ifadd_indicator==True, add default indicator handler as well.
- change_layout_tags(add=None, remove=None, replace=None)
Specify the current tags which are applied to every added layout elements.
add, remove specify, respectively, tags to be added, removed. replace` is specified, it completely replaces the set of current tags (before add and remove are applied).
- compress_grid_layout(sublayout=None)
Find all empty rows in a grid layout and shift them to the bottom
- contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
- 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), wheresublayoutis the sublayout name ("name"for the main layout), andlocationis a tuple(row, column, rowspan, colspan). If the given widget is not in this layout, returnNone.
- 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 (
Nonemeans all indicators)
- get_layout_shape(name=None)
Get shape
(rows, cols)of the current layout
- get_layout_tags()
Get the set of currently applied layout tags
- 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 (
Nonemeans 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, compress=False)
Insert a new column at the given location in the grid layout; if
compress==True, and there are an empty column to the right, shift and use that instead
- insert_row(row, sublayout=None, stretch=0, compress=False)
Insert a new row at the given location in the grid layout; if
compress==True, and there is an empty row below, shift and use that instead
- 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, tag=None, yield_layout_info=False)
Iterate over items contained in a given sublayout.
include is a tuple which contains items to iterate over; can include
"widget","layout", or"spacer". Ifnested==True, iterate over items in contained layouts and widgets as well. If tag is set, it specifies the tag to select the elements. Ifyield_layout_info==False, yield a 2-tuple(kind, element), wherekindcan be"widget","layout", or"spacer"; ifyield_layout_info==True, yield a 4-tuple(kind, element, layout, index), which includes the element’s containing layout and its index within.
- move_layout_element(element, location)
Move the given layout element to a new location
- remove_layout_element(element)
Remove a previously added layout element
- remove_sublayout_items(name=None, include='all', nested=True, tag=None, widget_action='remove')
Remove items within the sublayout with the given name (current by default).
include specifies which elements to include (can be a tuple containing
"widget","layout", or"spacer", or"all"), nested specifies if nested layouts and widgets are also checked, tag specifies a possible tag to select the elements on. widget_action can be"remove"(remove widgets and layouts), or"hide"(hide widgets without removing); spacers are always removed.
- 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
indexandstretch, 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
indexandstretch, or a single list of stretches for all rows.
- set_value(name, value)
Set value of a widget with the given name (
Nonemeans all values)
- setup_name(name)
Set the object’s name
- start()
Start the container.
Starts all the internal timers, and calls
startmethod 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
stopmethod for all the contained widgets.
- 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
withblock
- using_layout_tags(add=None, remove=None, replace=None)
Context manager for temporarily using different layout tags.
See
change_layout_tags()for details.
- using_new_sublayout(name, kind='grid', location=None)
Create a different sublayout and use it as default inside the
withblock.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,objectGeneric widget container.
Combines
IQContainermanagement of GUI values and timers withIQLayoutManagedWidgetmanagement 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 specifyinglocation="skip"inadd_child()(only add to the container).Simply a combination of
IQWidgetContainerandQWidget.- 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; iflocation=="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 whenclearorremove_childmethods are called; otherwise, simply itsclearmethod will be called, and its GUI values will be deleted.If gui_values_path is
FalseorNone, do not add it to the GUI values table; if it isTrue, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise,gui_values_pathspecifies 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 itssetup_gui_valuesto make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- add_decoration_label(text, location='next', tag=None)
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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_child()method.
- add_padding(kind='auto', location='next', stretch=0, tag=None)
Add a padding (expandable spacer) of the given kind to the given location.
kind can be
"vertical","horizontal","auto"(vertical forgridandvboxlayouts, horizontal forhbox), or"both"(stretches in both directions). If stretch is notNone, 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', tag=None)
Add a spacer with the given width and height to the given location.
If
stretch_height==Trueorstretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is notNone, 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==Trueand the container has been started (by callingstart()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==Trueand the container has been started (by callingstart()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 aDictionaryevery time it is set. Ifadd_indicator==True, add default indicator handler as well.
- change_layout_tags(add=None, remove=None, replace=None)
Specify the current tags which are applied to every added layout elements.
add, remove specify, respectively, tags to be added, removed. replace` is specified, it completely replaces the set of current tags (before add and remove are applied).
- clear()
Clear the container.
All the timers are stopped, all the contained widgets are cleared and removed.
- compress_grid_layout(sublayout=None)
Find all empty rows in a grid layout and shift them to the bottom
- contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
- 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), wheresublayoutis the sublayout name ("name"for the main layout), andlocationis a tuple(row, column, rowspan, colspan). If the given widget is not in this layout, returnNone.
- 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 (
Nonemeans all indicators)
- get_layout_shape(name=None)
Get shape
(rows, cols)of the current layout
- get_layout_tags()
Get the set of currently applied layout tags
- 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 (
Nonemeans 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, compress=False)
Insert a new column at the given location in the grid layout; if
compress==True, and there are an empty column to the right, shift and use that instead
- insert_row(row, sublayout=None, stretch=0, compress=False)
Insert a new row at the given location in the grid layout; if
compress==True, and there is an empty row below, shift and use that instead
- 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, tag=None, yield_layout_info=False)
Iterate over items contained in a given sublayout.
include is a tuple which contains items to iterate over; can include
"widget","layout", or"spacer". Ifnested==True, iterate over items in contained layouts and widgets as well. If tag is set, it specifies the tag to select the elements. Ifyield_layout_info==False, yield a 2-tuple(kind, element), wherekindcan be"widget","layout", or"spacer"; ifyield_layout_info==True, yield a 4-tuple(kind, element, layout, index), which includes the element’s containing layout and its index within.
- move_layout_element(element, location)
Move the given layout element to a new location
- 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_sublayout_items(name=None, include='all', nested=True, tag=None, widget_action='remove')
Remove items within the sublayout with the given name (current by default).
include specifies which elements to include (can be a tuple containing
"widget","layout", or"spacer", or"all"), nested specifies if nested layouts and widgets are also checked, tag specifies a possible tag to select the elements on. widget_action can be"remove"(remove widgets and layouts), or"hide"(hide widgets without removing); spacers are always removed.
- 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
indexandstretch, 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
indexandstretch, or a single list of stretches for all rows.
- set_value(name, value)
Set value of a widget with the given name (
Nonemeans 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
startmethod 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
stopmethod for all the contained widgets.
- 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
withblock
- using_layout_tags(add=None, remove=None, replace=None)
Context manager for temporarily using different layout tags.
See
change_layout_tags()for details.
- using_new_sublayout(name, kind='grid', location=None)
Create a different sublayout and use it as default inside the
withblock.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,objectAn extension of
IQWidgetContainerfor aQFrameQt 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; iflocation=="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 whenclearorremove_childmethods are called; otherwise, simply itsclearmethod will be called, and its GUI values will be deleted.If gui_values_path is
FalseorNone, do not add it to the GUI values table; if it isTrue, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise,gui_values_pathspecifies 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 itssetup_gui_valuesto make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- add_decoration_label(text, location='next', tag=None)
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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_child()method.
- add_padding(kind='auto', location='next', stretch=0, tag=None)
Add a padding (expandable spacer) of the given kind to the given location.
kind can be
"vertical","horizontal","auto"(vertical forgridandvboxlayouts, horizontal forhbox), or"both"(stretches in both directions). If stretch is notNone, 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', tag=None)
Add a spacer with the given width and height to the given location.
If
stretch_height==Trueorstretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is notNone, 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==Trueand the container has been started (by callingstart()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==Trueand the container has been started (by callingstart()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 aDictionaryevery time it is set. Ifadd_indicator==True, add default indicator handler as well.
- change_layout_tags(add=None, remove=None, replace=None)
Specify the current tags which are applied to every added layout elements.
add, remove specify, respectively, tags to be added, removed. replace` is specified, it completely replaces the set of current tags (before add and remove are applied).
- clear()
Clear the container.
All the timers are stopped, all the contained widgets are cleared and removed.
- compress_grid_layout(sublayout=None)
Find all empty rows in a grid layout and shift them to the bottom
- contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
- 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), wheresublayoutis the sublayout name ("name"for the main layout), andlocationis a tuple(row, column, rowspan, colspan). If the given widget is not in this layout, returnNone.
- 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 (
Nonemeans all indicators)
- get_layout_shape(name=None)
Get shape
(rows, cols)of the current layout
- get_layout_tags()
Get the set of currently applied layout tags
- 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 (
Nonemeans 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, compress=False)
Insert a new column at the given location in the grid layout; if
compress==True, and there are an empty column to the right, shift and use that instead
- insert_row(row, sublayout=None, stretch=0, compress=False)
Insert a new row at the given location in the grid layout; if
compress==True, and there is an empty row below, shift and use that instead
- 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, tag=None, yield_layout_info=False)
Iterate over items contained in a given sublayout.
include is a tuple which contains items to iterate over; can include
"widget","layout", or"spacer". Ifnested==True, iterate over items in contained layouts and widgets as well. If tag is set, it specifies the tag to select the elements. Ifyield_layout_info==False, yield a 2-tuple(kind, element), wherekindcan be"widget","layout", or"spacer"; ifyield_layout_info==True, yield a 4-tuple(kind, element, layout, index), which includes the element’s containing layout and its index within.
- move_layout_element(element, location)
Move the given layout element to a new location
- 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_sublayout_items(name=None, include='all', nested=True, tag=None, widget_action='remove')
Remove items within the sublayout with the given name (current by default).
include specifies which elements to include (can be a tuple containing
"widget","layout", or"spacer", or"all"), nested specifies if nested layouts and widgets are also checked, tag specifies a possible tag to select the elements on. widget_action can be"remove"(remove widgets and layouts), or"hide"(hide widgets without removing); spacers are always removed.
- 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
indexandstretch, 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
indexandstretch, or a single list of stretches for all rows.
- set_value(name, value)
Set value of a widget with the given name (
Nonemeans 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
startmethod 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
stopmethod for all the contained widgets.
- 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
withblock
- using_layout_tags(add=None, remove=None, replace=None)
Context manager for temporarily using different layout tags.
See
change_layout_tags()for details.
- using_new_sublayout(name, kind='grid', location=None)
Create a different sublayout and use it as default inside the
withblock.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,objectAn extension of
IQWidgetContainerfor aQDialogQt 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; iflocation=="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 whenclearorremove_childmethods are called; otherwise, simply itsclearmethod will be called, and its GUI values will be deleted.If gui_values_path is
FalseorNone, do not add it to the GUI values table; if it isTrue, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise,gui_values_pathspecifies 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 itssetup_gui_valuesto make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- add_decoration_label(text, location='next', tag=None)
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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_child()method.
- add_padding(kind='auto', location='next', stretch=0, tag=None)
Add a padding (expandable spacer) of the given kind to the given location.
kind can be
"vertical","horizontal","auto"(vertical forgridandvboxlayouts, horizontal forhbox), or"both"(stretches in both directions). If stretch is notNone, 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', tag=None)
Add a spacer with the given width and height to the given location.
If
stretch_height==Trueorstretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is notNone, 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==Trueand the container has been started (by callingstart()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==Trueand the container has been started (by callingstart()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 aDictionaryevery time it is set. Ifadd_indicator==True, add default indicator handler as well.
- change_layout_tags(add=None, remove=None, replace=None)
Specify the current tags which are applied to every added layout elements.
add, remove specify, respectively, tags to be added, removed. replace` is specified, it completely replaces the set of current tags (before add and remove are applied).
- clear()
Clear the container.
All the timers are stopped, all the contained widgets are cleared and removed.
- compress_grid_layout(sublayout=None)
Find all empty rows in a grid layout and shift them to the bottom
- contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
- 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), wheresublayoutis the sublayout name ("name"for the main layout), andlocationis a tuple(row, column, rowspan, colspan). If the given widget is not in this layout, returnNone.
- 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 (
Nonemeans all indicators)
- get_layout_shape(name=None)
Get shape
(rows, cols)of the current layout
- get_layout_tags()
Get the set of currently applied layout tags
- 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 (
Nonemeans 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, compress=False)
Insert a new column at the given location in the grid layout; if
compress==True, and there are an empty column to the right, shift and use that instead
- insert_row(row, sublayout=None, stretch=0, compress=False)
Insert a new row at the given location in the grid layout; if
compress==True, and there is an empty row below, shift and use that instead
- 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, tag=None, yield_layout_info=False)
Iterate over items contained in a given sublayout.
include is a tuple which contains items to iterate over; can include
"widget","layout", or"spacer". Ifnested==True, iterate over items in contained layouts and widgets as well. If tag is set, it specifies the tag to select the elements. Ifyield_layout_info==False, yield a 2-tuple(kind, element), wherekindcan be"widget","layout", or"spacer"; ifyield_layout_info==True, yield a 4-tuple(kind, element, layout, index), which includes the element’s containing layout and its index within.
- move_layout_element(element, location)
Move the given layout element to a new location
- 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_sublayout_items(name=None, include='all', nested=True, tag=None, widget_action='remove')
Remove items within the sublayout with the given name (current by default).
include specifies which elements to include (can be a tuple containing
"widget","layout", or"spacer", or"all"), nested specifies if nested layouts and widgets are also checked, tag specifies a possible tag to select the elements on. widget_action can be"remove"(remove widgets and layouts), or"hide"(hide widgets without removing); spacers are always removed.
- 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
indexandstretch, 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
indexandstretch, or a single list of stretches for all rows.
- set_value(name, value)
Set value of a widget with the given name (
Nonemeans 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
startmethod 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
stopmethod for all the contained widgets.
- 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
withblock
- using_layout_tags(add=None, remove=None, replace=None)
Context manager for temporarily using different layout tags.
See
change_layout_tags()for details.
- using_new_sublayout(name, kind='grid', location=None)
Create a different sublayout and use it as default inside the
withblock.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,objectAn extension of
IQWidgetContainerfor aQGroupBoxQt 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; iflocation=="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 whenclearorremove_childmethods are called; otherwise, simply itsclearmethod will be called, and its GUI values will be deleted.If gui_values_path is
FalseorNone, do not add it to the GUI values table; if it isTrue, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise,gui_values_pathspecifies 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 itssetup_gui_valuesto make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- add_decoration_label(text, location='next', tag=None)
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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_child()method.
- add_padding(kind='auto', location='next', stretch=0, tag=None)
Add a padding (expandable spacer) of the given kind to the given location.
kind can be
"vertical","horizontal","auto"(vertical forgridandvboxlayouts, horizontal forhbox), or"both"(stretches in both directions). If stretch is notNone, 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', tag=None)
Add a spacer with the given width and height to the given location.
If
stretch_height==Trueorstretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is notNone, 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==Trueand the container has been started (by callingstart()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==Trueand the container has been started (by callingstart()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 aDictionaryevery time it is set. Ifadd_indicator==True, add default indicator handler as well.
- change_layout_tags(add=None, remove=None, replace=None)
Specify the current tags which are applied to every added layout elements.
add, remove specify, respectively, tags to be added, removed. replace` is specified, it completely replaces the set of current tags (before add and remove are applied).
- clear()
Clear the container.
All the timers are stopped, all the contained widgets are cleared and removed.
- compress_grid_layout(sublayout=None)
Find all empty rows in a grid layout and shift them to the bottom
- contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
- 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), wheresublayoutis the sublayout name ("name"for the main layout), andlocationis a tuple(row, column, rowspan, colspan). If the given widget is not in this layout, returnNone.
- 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 (
Nonemeans all indicators)
- get_layout_shape(name=None)
Get shape
(rows, cols)of the current layout
- get_layout_tags()
Get the set of currently applied layout tags
- 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 (
Nonemeans 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, compress=False)
Insert a new column at the given location in the grid layout; if
compress==True, and there are an empty column to the right, shift and use that instead
- insert_row(row, sublayout=None, stretch=0, compress=False)
Insert a new row at the given location in the grid layout; if
compress==True, and there is an empty row below, shift and use that instead
- 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, tag=None, yield_layout_info=False)
Iterate over items contained in a given sublayout.
include is a tuple which contains items to iterate over; can include
"widget","layout", or"spacer". Ifnested==True, iterate over items in contained layouts and widgets as well. If tag is set, it specifies the tag to select the elements. Ifyield_layout_info==False, yield a 2-tuple(kind, element), wherekindcan be"widget","layout", or"spacer"; ifyield_layout_info==True, yield a 4-tuple(kind, element, layout, index), which includes the element’s containing layout and its index within.
- move_layout_element(element, location)
Move the given layout element to a new location
- 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_sublayout_items(name=None, include='all', nested=True, tag=None, widget_action='remove')
Remove items within the sublayout with the given name (current by default).
include specifies which elements to include (can be a tuple containing
"widget","layout", or"spacer", or"all"), nested specifies if nested layouts and widgets are also checked, tag specifies a possible tag to select the elements on. widget_action can be"remove"(remove widgets and layouts), or"hide"(hide widgets without removing); spacers are always removed.
- 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
indexandstretch, 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
indexandstretch, or a single list of stretches for all rows.
- set_value(name, value)
Set value of a widget with the given name (
Nonemeans all values)
- setup_name(name)
Set the object’s name
- start()
Start the container.
Starts all the internal timers, and calls
startmethod 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
stopmethod for all the contained widgets.
- 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
withblock
- using_layout_tags(add=None, remove=None, replace=None)
Context manager for temporarily using different layout tags.
See
change_layout_tags()for details.
- using_new_sublayout(name, kind='grid', location=None)
Create a different sublayout and use it as default inside the
withblock.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,objectAn extension of
IQWidgetContainerfor aQScrollAreaQt base class.Due to Qt organization, this container is “intermediate”: it contains only a single
QWidgetContainerwidget (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; iflocation=="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 whenclearorremove_childmethods are called; otherwise, simply itsclearmethod will be called, and its GUI values will be deleted.If gui_values_path is
FalseorNone, do not add it to the GUI values table; if it isTrue, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise,gui_values_pathspecifies 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 itssetup_gui_valuesto make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- add_decoration_label(text, location='next', tag=None)
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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_child()method.
- add_padding(kind='auto', location='next', stretch=0, tag=None)
Add a padding (expandable spacer) of the given kind to the given location.
kind can be
"vertical","horizontal","auto"(vertical forgridandvboxlayouts, horizontal forhbox), or"both"(stretches in both directions). If stretch is notNone, 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', tag=None)
Add a spacer with the given width and height to the given location.
If
stretch_height==Trueorstretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is notNone, 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==Trueand the container has been started (by callingstart()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==Trueand the container has been started (by callingstart()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 aDictionaryevery time it is set. Ifadd_indicator==True, add default indicator handler as well.
- change_layout_tags(add=None, remove=None, replace=None)
Specify the current tags which are applied to every added layout elements.
add, remove specify, respectively, tags to be added, removed. replace` is specified, it completely replaces the set of current tags (before add and remove are applied).
- clear()
Clear the container.
All the timers are stopped, all the contained widgets are cleared and removed.
- compress_grid_layout(sublayout=None)
Find all empty rows in a grid layout and shift them to the bottom
- contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
- 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), wheresublayoutis the sublayout name ("name"for the main layout), andlocationis a tuple(row, column, rowspan, colspan). If the given widget is not in this layout, returnNone.
- 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 (
Nonemeans all indicators)
- get_layout_shape(name=None)
Get shape
(rows, cols)of the current layout
- get_layout_tags()
Get the set of currently applied layout tags
- 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 (
Nonemeans 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, compress=False)
Insert a new column at the given location in the grid layout; if
compress==True, and there are an empty column to the right, shift and use that instead
- insert_row(row, sublayout=None, stretch=0, compress=False)
Insert a new row at the given location in the grid layout; if
compress==True, and there is an empty row below, shift and use that instead
- 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, tag=None, yield_layout_info=False)
Iterate over items contained in a given sublayout.
include is a tuple which contains items to iterate over; can include
"widget","layout", or"spacer". Ifnested==True, iterate over items in contained layouts and widgets as well. If tag is set, it specifies the tag to select the elements. Ifyield_layout_info==False, yield a 2-tuple(kind, element), wherekindcan be"widget","layout", or"spacer"; ifyield_layout_info==True, yield a 4-tuple(kind, element, layout, index), which includes the element’s containing layout and its index within.
- move_layout_element(element, location)
Move the given layout element to a new location
- 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_sublayout_items(name=None, include='all', nested=True, tag=None, widget_action='remove')
Remove items within the sublayout with the given name (current by default).
include specifies which elements to include (can be a tuple containing
"widget","layout", or"spacer", or"all"), nested specifies if nested layouts and widgets are also checked, tag specifies a possible tag to select the elements on. widget_action can be"remove"(remove widgets and layouts), or"hide"(hide widgets without removing); spacers are always removed.
- 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
indexandstretch, 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
indexandstretch, or a single list of stretches for all rows.
- set_value(name, value)
Set value of a widget with the given name (
Nonemeans 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
startmethod 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
stopmethod for all the contained widgets.
- 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
withblock
- using_layout_tags(add=None, remove=None, replace=None)
Context manager for temporarily using different layout tags.
See
change_layout_tags()for details.
- using_new_sublayout(name, kind='grid', location=None)
Create a different sublayout and use it as default inside the
withblock.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
clearmethods 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
FalseorNone, do not add it to the GUI values table; if it isTrue, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise,gui_values_pathspecifies the path under which the widget values are stored. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- 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 itssetup_gui_valuesto make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- 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==Trueand the container has been started (by callingstart()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==Trueand the container has been started (by callingstart()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 aDictionaryevery time it is set. Ifadd_indicator==True, add default indicator handler as well.
- contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
- 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 (
Nonemeans all indicators)
- get_value(name=None)
Get value of a widget with the given name (
Nonemeans 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 (
Nonemeans all values)
- setup_name(name)
Set the object’s name
- start()
Start the container.
Starts all the internal timers, and calls
startmethod 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
stopmethod for all the contained widgets.
- 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,objectContainer which manages tab widget.
Does not have its own layout, but can add or remove tabs, which are represented as
QFrameContainerwidgets.- 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 (
Nonemeans adding to the end, negative values count from the end). If widget isNone, 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 inadd_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
clearmethods of all contained widgets, remove all widgets from the values table, remove all widgets from the table.
- get_name_by_index(idx)[source]
Return the name of the tab at a given index, or
Noneif this tab is not being tracked
- 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
FalseorNone, do not add it to the GUI values table; if it isTrue, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise,gui_values_pathspecifies the path under which the widget values are stored. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- 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 itssetup_gui_valuesto make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- 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==Trueand the container has been started (by callingstart()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==Trueand the container has been started (by callingstart()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 aDictionaryevery time it is set. Ifadd_indicator==True, add default indicator handler as well.
- contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
- 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 (
Nonemeans all indicators)
- get_value(name=None)
Get value of a widget with the given name (
Nonemeans 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 (
Nonemeans all values)
- setup(name=None)
Setup the container by initializing its GUI values and setting the
ctlattribute
- setup_name(name)
Set the object’s name
- start()
Start the container.
Starts all the internal timers, and calls
startmethod 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
stopmethod for all the contained widgets.
- 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:
objectExpanded text edit.
Maintains internally stored consistent value (which can be, e.g., accessed from different threads).
- 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.
- value_entered = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
Signal emitted when value is entered (regardless of whether it stayed the same)
- value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
Signal emitted when value is changed
- show_value(interrupt_edit=False)[source]
Display currently stored text value
If
interrupt_edit==Trueand 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. Ifinterrupt_edit==Trueand 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:
objectLabview-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 (
Nonemeans 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)
- 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.LimitErrorif it should be ignored; or it can be a tuple(lower, upper, action, value_type), wherelowerandupperare the limits (Nonemeans no limits),actiondefines out-of-limit action (either"ignore"to ignore entered value, or"coerce"to truncate to the nearest limit), andvalue_typecan beNone(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 theformatter.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 toset_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).
- value_entered = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
Signal emitted when value is entered (regardless of whether it stayed the same)
- value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
Signal emitted when value is changed
- show_value(interrupt_edit=False, preserve_cursor_order=True)[source]
Display currently stored numerical value
If
interrupt_edit==Falseand the edit is currently being modified by the user, don’t update the display. Ifpreserve_cursor_order==Trueand 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 thevalue_changedsignal; otherwise, change value silently. Ifinterrupt_edit==Falseand the edit is currently being modified by the user, don’t update the display (but still update the internally stored value). Ifpreserve_cursor_order==Trueand 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:
objectLabview-style text label.
The main difference from the standard
QLabelis the changed event.- clicked = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
- value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
Signal emitted when value is changed
- class pylablib.core.gui.widgets.label.EnumLabel(parent, options, value=None, prep=None, styles=None, default_style='')[source]
Bases:
objectLabview-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
Falsemean the same thing)- clicked = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
- 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.
- set_styles(styles=None, default_style='')[source]
Set the dictionary of styles
{value: style}and the default style
- value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
Signal emitted when value is changed
- class pylablib.core.gui.widgets.label.NumLabel(parent, value=None, limiter=None, formatter=None, allow_text=True)[source]
Bases:
objectLabview-style numerical label.
Supports different number representations and metric prefixes.
- Parameters:
parent – parent widget
value – initial value (
Nonemeans 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='133174990151376'>
- 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.LimitErrorif it should be ignored; or it can be a tuple(lower, upper, action, value_type), wherelowerandupperare the limits (Nonemeans no limits),actiondefines out-of-limit action (either"ignore"to ignore entered value, or"coerce"to truncate to the nearest limit), andvalue_typecan beNone(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 theformatter.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 toset_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.
- value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
Signal emitted when value is changed
pylablib.core.gui.widgets.layout_manager module
- class pylablib.core.gui.widgets.layout_manager.IQLayoutManagedWidget(*args, **kwargs)[source]
Bases:
objectGUI 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 usingadd_to_layout(). In addition, it can directly add named sublayouts usingadd_sublayout()method.Abstract mix-in class, which needs to be added to a class inheriting from
QWidget. Alternatively, one can directly useQLayoutManagedWidget, which already inherits fromQWidget.- 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)
- change_layout_tags(add=None, remove=None, replace=None)[source]
Specify the current tags which are applied to every added layout elements.
add, remove specify, respectively, tags to be added, removed. replace` is specified, it completely replaces the set of current tags (before add and remove are applied).
- using_layout_tags(add=None, remove=None, replace=None)[source]
Context manager for temporarily using different layout tags.
See
change_layout_tags()for details.
- 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).
- get_element_position(element)[source]
Get the sublayout and the position of the given widget.
Return tuple
(sublayout, location), wheresublayoutis the sublayout name ("name"for the main layout), andlocationis a tuple(row, column, rowspan, colspan). If the given widget is not in this layout, returnNone.
- 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
withblock.kind can be
"grid","vbox"(vertical single-column box), or"hbox"(horizontal single-row box).
- iter_sublayout_items(name=None, include=('widget',), nested=False, tag=None, yield_layout_info=False)[source]
Iterate over items contained in a given sublayout.
include is a tuple which contains items to iterate over; can include
"widget","layout", or"spacer". Ifnested==True, iterate over items in contained layouts and widgets as well. If tag is set, it specifies the tag to select the elements. Ifyield_layout_info==False, yield a 2-tuple(kind, element), wherekindcan be"widget","layout", or"spacer"; ifyield_layout_info==True, yield a 4-tuple(kind, element, layout, index), which includes the element’s containing layout and its index within.
- remove_sublayout_items(name=None, include='all', nested=True, tag=None, widget_action='remove')[source]
Remove items within the sublayout with the given name (current by default).
include specifies which elements to include (can be a tuple containing
"widget","layout", or"spacer", or"all"), nested specifies if nested layouts and widgets are also checked, tag specifies a possible tag to select the elements on. widget_action can be"remove"(remove widgets and layouts), or"hide"(hide widgets without removing); spacers are always removed.
- add_spacer(height=0, width=0, stretch_height=False, stretch_width=False, stretch=0, location='next', tag=None)[source]
Add a spacer with the given width and height to the given location.
If
stretch_height==Trueorstretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is notNone, 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, tag=None)[source]
Add a padding (expandable spacer) of the given kind to the given location.
kind can be
"vertical","horizontal","auto"(vertical forgridandvboxlayouts, horizontal forhbox), or"both"(stretches in both directions). If stretch is notNone, 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
indexandstretch, 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
indexandstretch, or a single list of stretches for all columns.
- add_decoration_label(text, location='next', tag=None)[source]
Add a decoration text label with the given text
- insert_row(row, sublayout=None, stretch=0, compress=False)[source]
Insert a new row at the given location in the grid layout; if
compress==True, and there is an empty row below, shift and use that instead
- insert_column(col, sublayout=None, stretch=0, compress=False)[source]
Insert a new column at the given location in the grid layout; if
compress==True, and there are an empty column to the right, shift and use that instead
- class pylablib.core.gui.widgets.layout_manager.QLayoutManagedWidget(*args, **kwargs)[source]
Bases:
IQLayoutManagedWidget,objectGUI 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 usingadd_to_layout(). In addition, it can directly add named sublayouts usingadd_sublayout()method.Simply a combination of
IQLayoutManagedWidgetandQWidget.- add_decoration_label(text, location='next', tag=None)
Add a decoration text label with the given text
- add_padding(kind='auto', location='next', stretch=0, tag=None)
Add a padding (expandable spacer) of the given kind to the given location.
kind can be
"vertical","horizontal","auto"(vertical forgridandvboxlayouts, horizontal forhbox), or"both"(stretches in both directions). If stretch is notNone, 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', tag=None)
Add a spacer with the given width and height to the given location.
If
stretch_height==Trueorstretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is notNone, 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).
- change_layout_tags(add=None, remove=None, replace=None)
Specify the current tags which are applied to every added layout elements.
add, remove specify, respectively, tags to be added, removed. replace` is specified, it completely replaces the set of current tags (before add and remove are applied).
- clear()
Clear the layout and remove all the added elements
- compress_grid_layout(sublayout=None)
Find all empty rows in a grid layout and shift them to the bottom
- get_element_position(element)
Get the sublayout and the position of the given widget.
Return tuple
(sublayout, location), wheresublayoutis the sublayout name ("name"for the main layout), andlocationis a tuple(row, column, rowspan, colspan). If the given widget is not in this layout, returnNone.
- get_layout_shape(name=None)
Get shape
(rows, cols)of the current layout
- get_layout_tags()
Get the set of currently applied layout tags
- 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, compress=False)
Insert a new column at the given location in the grid layout; if
compress==True, and there are an empty column to the right, shift and use that instead
- insert_row(row, sublayout=None, stretch=0, compress=False)
Insert a new row at the given location in the grid layout; if
compress==True, and there is an empty row below, shift and use that instead
- iter_sublayout_items(name=None, include=('widget',), nested=False, tag=None, yield_layout_info=False)
Iterate over items contained in a given sublayout.
include is a tuple which contains items to iterate over; can include
"widget","layout", or"spacer". Ifnested==True, iterate over items in contained layouts and widgets as well. If tag is set, it specifies the tag to select the elements. Ifyield_layout_info==False, yield a 2-tuple(kind, element), wherekindcan be"widget","layout", or"spacer"; ifyield_layout_info==True, yield a 4-tuple(kind, element, layout, index), which includes the element’s containing layout and its index within.
- move_layout_element(element, location)
Move the given layout element to a new location
- remove_layout_element(element)
Remove a previously added layout element
- remove_sublayout_items(name=None, include='all', nested=True, tag=None, widget_action='remove')
Remove items within the sublayout with the given name (current by default).
include specifies which elements to include (can be a tuple containing
"widget","layout", or"spacer", or"all"), nested specifies if nested layouts and widgets are also checked, tag specifies a possible tag to select the elements on. widget_action can be"remove"(remove widgets and layouts), or"hide"(hide widgets without removing); spacers are always removed.
- set_column_stretch(*args, layout=None)
Set column stretch for a given layout.
Takes either two arguments
indexandstretch, 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
indexandstretch, 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
withblock
- using_layout_tags(add=None, remove=None, replace=None)
Context manager for temporarily using different layout tags.
See
change_layout_tags()for details.
- using_new_sublayout(name, kind='grid', location=None)
Create a different sublayout and use it as default inside the
withblock.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:
QWidgetContainerGUI 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:.hfor getting the value handler (i.e.,self.get_handler(name)is equivalent toself.h[name]),.wfor getting the underlying widget (i.e.,self.get_widget(name)is equivalent toself.w[name]),.vfor settings/getting values using the default getting method (equivalent to.wvifcache_values=Falseinsetup(), and to.cvotherwise),.wvfor settings/getting current current widget values without caching (i.e.,self.get_value(name)is equivalent toself.v[name], andself.set_value(name, value)is equivalent toself.v[name]=value),.cvfor settings/getting values using cached value’s table for getting (i.e.,self.current_values[name]is equivalent toself.cv[name], andself.set_value(name, value)is equivalent toself.cv[name]=value), (i.e.,self.get_value(name)is equivalent toself.v[name], andself.set_value(name, value)is equivalent toself.v[name]=value),.ifor settings/getting indicator values (i.e.,self.get_indicator(name)is equivalent toself.i[name], andself.set_indicator(name, value)is equivalent toself.i[name]=value).vsfor getting the value changed Qt signal (i.e.,self.get_value_changed_signal(name)is equivalent toself.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, andupdate_indicators) are automatically called in the GUI thread.cache_values (bool) – if
Trueor"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 (unlikeget_value()orget_all_values()withgui_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
Falseandset_value()method is called while the widget has user focus, ignore the value; note thatset_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
withblock.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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_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 layoutvalue_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 tosetup()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 iflabel=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’scontained_value_changedevent
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_indicatormethods 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 lateradd_change_event (bool) – if
True, changing of the widget’s value emits the table’scontained_value_changedevent
Return the widget’s value handler
- add_virtual_element(name, value=None, multivalued=False, on_set_value='store', signal_kind='none', 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 aDictionaryevery time it is set. on_set_value specifies the behavior when value is set; can be"store"(store as the current value and return onget_valuelater) or"ignore"(keep the original value) signal_kind specifies value changed signal kind; can be"none"(no signal),"direct"(emulation of direct-connection signal, which is called whenever the value changes), or"dummy"(emulation of direct-connection signal, which is never called). Ifadd_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:
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)
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:
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:
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, styles=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 (dict) – dictionary
{index_value: text}which converts values into textout_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
Falsemean the same thing)styles – a dictionary
{value: style}which defines stylesheet styles based on the value (if some values are not in the dictionary, use default no-style 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_style_indicator_label(name, caption, options=(True, False), value=None, out_of_range='error', prep='auto', styles=None, label=None, location=None, tooltip=None, add_change_event=False, virtual=False)[source]
Add a label to the table with a fixed caption but whose style indicates the value.
- Parameters:
name (str) – widget name (used to reference its value in the values table)
caption – text on the label
options (list) – list with the possible values
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
Falsemean the same thing)styles – a dictionary
{value: style}which defines stylesheet styles based on the value (if some values are not in the dictionary, use default no-style value); can be a single string value, which gets assigned toTruevaluevirtual (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; seelimiter.as_limiter()for detailsformatter (tuple) – either
"int"(for integer values), or tuple specifying floating value format; seeformatter.as_formatter()for detailsvirtual (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 editvirtual (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; seeNumEdit.set_limiter()for detailsformatter (tuple) – either
"int"(for integer values), or tuple specifying floating value format; seeNumEdit.set_formatter()for detailscustom_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:
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().
- add_button_selector(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 (
Nonemeans 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_indicator_widget(name)[source]
Get indicator widget for a parameter with the given name, or
Noneif this parameter has no indicator label
- get_label_widget(name)[source]
Get label widget for a parameter with the given name, or
Noneif this parameter has no label
- 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 (
Nonemeans 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 thecontained_value_changedsignal.
- 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; iflocation=="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 whenclearorremove_childmethods are called; otherwise, simply itsclearmethod will be called, and its GUI values will be deleted.If gui_values_path is
FalseorNone, do not add it to the GUI values table; if it isTrue, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise,gui_values_pathspecifies 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 itssetup_gui_valuesto make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- add_decoration_label(text, location='next', tag=None)
Add a decoration text label with the given text
- add_padding(kind='auto', location='next', stretch=0, tag=None)
Add a padding (expandable spacer) of the given kind to the given location.
kind can be
"vertical","horizontal","auto"(vertical forgridandvboxlayouts, horizontal forhbox), or"both"(stretches in both directions). If stretch is notNone, 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', tag=None)
Add a spacer with the given width and height to the given location.
If
stretch_height==Trueorstretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is notNone, 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==Trueand the container has been started (by callingstart()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==Trueand the container has been started (by callingstart()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).
- change_layout_tags(add=None, remove=None, replace=None)
Specify the current tags which are applied to every added layout elements.
add, remove specify, respectively, tags to be added, removed. replace` is specified, it completely replaces the set of current tags (before add and remove are applied).
- compress_grid_layout(sublayout=None)
Find all empty rows in a grid layout and shift them to the bottom
- contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
- get_element_position(element)
Get the sublayout and the position of the given widget.
Return tuple
(sublayout, location), wheresublayoutis the sublayout name ("name"for the main layout), andlocationis a tuple(row, column, rowspan, colspan). If the given widget is not in this layout, returnNone.
- 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_layout_tags()
Get the set of currently applied layout tags
- 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, compress=False)
Insert a new column at the given location in the grid layout; if
compress==True, and there are an empty column to the right, shift and use that instead
- insert_row(row, sublayout=None, stretch=0, compress=False)
Insert a new row at the given location in the grid layout; if
compress==True, and there is an empty row below, shift and use that instead
- 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, tag=None, yield_layout_info=False)
Iterate over items contained in a given sublayout.
include is a tuple which contains items to iterate over; can include
"widget","layout", or"spacer". Ifnested==True, iterate over items in contained layouts and widgets as well. If tag is set, it specifies the tag to select the elements. Ifyield_layout_info==False, yield a 2-tuple(kind, element), wherekindcan be"widget","layout", or"spacer"; ifyield_layout_info==True, yield a 4-tuple(kind, element, layout, index), which includes the element’s containing layout and its index within.
- move_layout_element(element, location)
Move the given layout element to a new location
- remove_layout_element(element)
Remove a previously added layout element
- remove_sublayout_items(name=None, include='all', nested=True, tag=None, widget_action='remove')
Remove items within the sublayout with the given name (current by default).
include specifies which elements to include (can be a tuple containing
"widget","layout", or"spacer", or"all"), nested specifies if nested layouts and widgets are also checked, tag specifies a possible tag to select the elements on. widget_action can be"remove"(remove widgets and layouts), or"hide"(hide widgets without removing); spacers are always removed.
- set_column_stretch(*args, layout=None)
Set column stretch for a given layout.
Takes either two arguments
indexandstretch, 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
indexandstretch, 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
startmethod 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
stopmethod for all the contained widgets.
- using_layout(name)
Use a different sublayout as default inside the
withblock
- using_layout_tags(add=None, remove=None, replace=None)
Context manager for temporarily using different layout tags.
See
change_layout_tags()for details.
- class pylablib.core.gui.widgets.param_table.StatusTable(parent=None, name=None)[source]
Bases:
ParamTableExpansion of
ParamTablewhich 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, andupdate_indicators) are automatically called in the GUI thread.cache_values (bool) – if
Trueor"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 (unlikeget_value()orget_all_values()withgui_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
Falseandset_value()method is called while the widget has user focus, ignore the value; note thatset_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 linesrcs (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, usesrcsname provided upon creation. If path isNone, usetagsname 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:
Rest of the arguments and the return value are the same as
add_simple_widget().
- add_button_selector(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_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:
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; iflocation=="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 whenclearorremove_childmethods are called; otherwise, simply itsclearmethod will be called, and its GUI values will be deleted.If gui_values_path is
FalseorNone, do not add it to the GUI values table; if it isTrue, add it under the same root (path=="") if it’s a container, and under name if it’s not; otherwise,gui_values_pathspecifies 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 itssetup_gui_valuesto make it share the same GUI values; otherwise, simply add it to the GUI values under the given path. ifadd_change_event==True, changing of the widget’s value emits the container’scontained_value_changedevent
- 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_indicatormethods 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 lateradd_change_event (bool) – if
True, changing of the widget’s value emits the table’scontained_value_changedevent
Return the widget’s value handler
- add_decoration_label(text, location='next', tag=None)
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)
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, styles=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 (dict) – dictionary
{index_value: text}which converts values into textout_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
Falsemean the same thing)styles – a dictionary
{value: style}which defines stylesheet styles based on the value (if some values are not in the dictionary, use default no-style 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_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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_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. Ifno_margins==True, the frame will have no inner layout margins. The other parameters are the same as inadd_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; seeNumEdit.set_limiter()for detailsformatter (tuple) – either
"int"(for integer values), or tuple specifying floating value format; seeNumEdit.set_formatter()for detailscustom_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; seelimiter.as_limiter()for detailsformatter (tuple) – either
"int"(for integer values), or tuple specifying floating value format; seeformatter.as_formatter()for detailsvirtual (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, tag=None)
Add a padding (expandable spacer) of the given kind to the given location.
kind can be
"vertical","horizontal","auto"(vertical forgridandvboxlayouts, horizontal forhbox), or"both"(stretches in both directions). If stretch is notNone, 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:
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 layoutvalue_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 tosetup()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 iflabel=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’scontained_value_changedevent
Return the widget’s value handler
- add_spacer(height=0, width=0, stretch_height=False, stretch_width=False, stretch=0, location='next', tag=None)
Add a spacer with the given width and height to the given location.
If
stretch_height==Trueorstretch_width==True, the widget will stretch in these directions; otherwise, the widget size is fixed. If stretch is notNone, 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_style_indicator_label(name, caption, options=(True, False), value=None, out_of_range='error', prep='auto', styles=None, label=None, location=None, tooltip=None, add_change_event=False, virtual=False)
Add a label to the table with a fixed caption but whose style indicates the value.
- Parameters:
name (str) – widget name (used to reference its value in the values table)
caption – text on the label
options (list) – list with the possible values
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
Falsemean the same thing)styles – a dictionary
{value: style}which defines stylesheet styles based on the value (if some values are not in the dictionary, use default no-style value); can be a single string value, which gets assigned toTruevaluevirtual (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_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 editvirtual (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:
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==Trueand the container has been started (by callingstart()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==Trueand the container has been started (by callingstart()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, on_set_value='store', signal_kind='none', 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 aDictionaryevery time it is set. on_set_value specifies the behavior when value is set; can be"store"(store as the current value and return onget_valuelater) or"ignore"(keep the original value) signal_kind specifies value changed signal kind; can be"none"(no signal),"direct"(emulation of direct-connection signal, which is called whenever the value changes), or"dummy"(emulation of direct-connection signal, which is never called). Ifadd_indicator==True, add default indicator handler as well.
- change_layout_tags(add=None, remove=None, replace=None)
Specify the current tags which are applied to every added layout elements.
add, remove specify, respectively, tags to be added, removed. replace` is specified, it completely replaces the set of current tags (before add and remove are applied).
- clear(disconnect=False)
Clear the table (remove all widgets)
If
disconnect==True, also disconnect all slots connected to thecontained_value_changedsignal.
- compress_grid_layout(sublayout=None)
Find all empty rows in a grid layout and shift them to the bottom
- contained_value_changed = <Mock name='mock.QtCore.pyqtSignal()' id='133174990151376'>
- 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), wheresublayoutis the sublayout name ("name"for the main layout), andlocationis a tuple(row, column, rowspan, colspan). If the given widget is not in this layout, returnNone.
- 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 (
Nonemeans all indicators)
- get_indicator_widget(name)
Get indicator widget for a parameter with the given name, or
Noneif this parameter has no indicator label
- get_label_widget(name)
Get label widget for a parameter with the given name, or
Noneif this parameter has no label
- get_layout_shape(name=None)
Get shape
(rows, cols)of the current layout
- get_layout_tags()
Get the set of currently applied layout tags
- 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 (
Nonemeans 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, compress=False)
Insert a new column at the given location in the grid layout; if
compress==True, and there are an empty column to the right, shift and use that instead
- insert_row(row, sublayout=None, stretch=0, compress=False)
Insert a new row at the given location in the grid layout; if
compress==True, and there is an empty row below, shift and use that instead
- 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, tag=None, yield_layout_info=False)
Iterate over items contained in a given sublayout.
include is a tuple which contains items to iterate over; can include
"widget","layout", or"spacer". Ifnested==True, iterate over items in contained layouts and widgets as well. If tag is set, it specifies the tag to select the elements. Ifyield_layout_info==False, yield a 2-tuple(kind, element), wherekindcan be"widget","layout", or"spacer"; ifyield_layout_info==True, yield a 4-tuple(kind, element, layout, index), which includes the element’s containing layout and its index within.
- move_layout_element(element, location)
Move the given layout element to a new location
- 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_sublayout_items(name=None, include='all', nested=True, tag=None, widget_action='remove')
Remove items within the sublayout with the given name (current by default).
include specifies which elements to include (can be a tuple containing
"widget","layout", or"spacer", or"all"), nested specifies if nested layouts and widgets are also checked, tag specifies a possible tag to select the elements on. widget_action can be"remove"(remove widgets and layouts), or"hide"(hide widgets without removing); spacers are always removed.
- 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
indexandstretch, 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
indexandstretch, 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
startmethod 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
stopmethod for all the contained widgets.
- 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
withblock
- using_layout_tags(add=None, remove=None, replace=None)
Context manager for temporarily using different layout tags.
See
change_layout_tags()for details.
- using_new_sublayout(name, kind='grid', location=('next', 0, 1, 'end'))
Create a different sublayout and use it as default inside the
withblock.kind can be
"grid","vbox"(vertical single-column box), or"hbox"(horizontal single-row box).