nspyre.gui.widgets.main
Creates an interface that allows the user to easily launch Qt widgets. The
widgets are placed in a pyqtgraph DockArea
.
Module Contents
Classes
Represents an arbitrary QWidget that can be loaded from the MainWidget. |
|
Qt widget for loading other QWidgets. |
- class nspyre.gui.widgets.main.MainWidgetItem(module, cls, args=None, kwargs=None, stretch=None)
Represents an arbitrary QWidget that can be loaded from the MainWidget.
- Parameters:
module (types.ModuleType) – Python module that contains
cls
. The module will be reloaded when the user clicks the “Load” button.cls (str) – Python class name as a string. The class must descend from
QWidget
. An instance of this class will be created when the user tries to load the widget and it will be added to theDockArea
.args (Optional[list]) – Arguments to pass to
cls.__init__
.kwargs (Optional[dict]) – Keyword arguments to pass to the
cls.__init__
.stretch (Optional[tuple]) – The dock stretch factor
(stretch_x, stretch_y)
(see DockArea docs)
- class nspyre.gui.widgets.main.MainWidget(widgets, font_size='18px')
Qt widget for loading other QWidgets. It displays a hierarchy of widgets for the user to select and launch, and a pyqtgraph
DockArea
where they are displayed. The widgets dictionary passed to__init__
can contain sub-dictionaries in order to group widgets together.Typical usage example:
import my_module import nspyre from nspyre import nspyreApp from nspyre import MainWidget from nspyre import MainWidgetItem # Create Qt application and apply nspyre visual settings. app = nspyreApp() # Create the GUI. main_widget = MainWidget({ 'Experiments': { 'ODMR': MainWidgetItem(my_module, 'ODMRWidget'), }, 'Plot': MainWidgetItem(nspyre.gui.widgets.flex_line_plot, 'FlexLinePlotWidget'), 'Data': { 'Save': MainWidgetItem(nspyre.gui.widgets.save_widget, 'SaveWidget'), 'Load': MainWidgetItem(nspyre.gui.widgets.load_widget, 'LoadWidget'), } }) main_widget.show() # Run the GUI event loop. app.exec()
- Parameters:
widgets (Dict) – See example usage for the required form.
font_size (str) – Dock label font size as a string (e.g. ‘14px’).