1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
Overview
========
When developping scientific software, from the simplest script to the
most complex application, one systematically needs to manipulate data sets
(e.g. parameters for a data processing feature).
These data sets may consist of various data types: real numbers (e.g. physical
quantities), integers (e.g. array indexes), strings (e.g. filenames),
booleans (e.g. enable/disable an option), and so on.
Most of the time, the programmer will need the following features:
* allow the user to enter each parameter through a graphical user interface,
using widgets which are adapted to data types (e.g. a single combo box or
check boxes are suitable for presenting an option selection among
multiple choices)
* entered values have to be stored by the program with a convention which
is again adapted to data types (e.g. when storing a combo box selection
value, should we store the option string, the list index or an
associated key?)
* showing the stored values in a dialog box or within a graphical user
interface layout, again with widgets adapted to data types
* using the stored values easily (e.g. for data processing) by regrouping
parameters in data structures
* using those data structures to easily construct application data models
(e.g. for storing application settings or data processing parameters)
and to serialize and deserialize them (i.e. save and load them to/from
HDF5, JSON or INI files)
* update and restore a data set to/from a dictionary
* generate a data set from a function signature (i.e. a function prototype)
and use it to automatically generate a graphical user interface for
calling the function
This library aims to provide these features thanks to automatic graphical user
interface generation for data set editing and display. Widgets inside GUIs are
automatically generated depending on each data item type.
Jupyter Notebook and Interactive Python Support
------------------------------------------------
:mod:`guidata` provides enhanced support for interactive Python environments:
**Rich HTML display in Jupyter notebooks:**
DataSet objects and LabeledEnum values automatically render as styled HTML tables
when displayed in Jupyter notebooks. This is powered by the ``_repr_html_()`` method,
which Jupyter calls automatically when displaying objects as cell output.
.. code-block:: python
import guidata.dataset as gds
class Parameters(gds.DataSet):
"""Processing parameters"""
threshold = gds.FloatItem("Threshold", default=0.5)
enabled = gds.BoolItem("Enable processing", default=True)
params = Parameters()
params # Displays as a styled HTML table in Jupyter
**Interactive attribute discovery:**
When working in a Python shell or notebook, ``repr(dataset)`` (or simply typing
the variable name) shows attribute names instead of labels, making it easy to
discover the programmatic names needed to access or modify dataset items:
.. code-block:: python
>>> params = Parameters()
>>> params # Shows attribute names for programmatic access
Processing parameters:
threshold: 0.5 (FloatItem)
enabled: True (BoolItem)
>>> print(params) # Shows user-friendly labels
Processing parameters:
Threshold: 0.5
Enable processing: ☑
The :mod:`guidata` library provides the following modules:
* :py:mod:`guidata.dataset`: data set definition and manipulation
* :py:mod:`guidata.widgets`: ready-to-use Qt widgets (console, code editor, array editor, etc.)
* :py:mod:`guidata.qthelpers`: Qt helpers
* :py:mod:`guidata.configtools`: library/application data management
* :py:mod:`guidata.guitest`: automatic GUI-based test launcher
* :py:mod:`guidata.utils`: utilities
|