dataset¶
The guidata.dataset
package provides the core features for data set
display and editing with automatically generated graphical user interfaces.
dataset.dataitems¶
The guidata.dataset.dataitems
module contains implementation for
concrete DataItems.
- class guidata.dataset.dataitems.NumericTypeItem(label, default=None, min=None, max=None, nonzero=None, unit='', help='', check=True)[source]¶
Numeric data item
- class guidata.dataset.dataitems.FloatItem(label, default=None, min=None, max=None, nonzero=None, unit='', step=0.1, slider=False, help='', check=True)[source]¶
- Construct a float data item
label [string]: name
default [float]: default value (optional)
min [float]: minimum value (optional)
max [float]: maximum value (optional)
slider [bool]: if True, shows a slider widget right after the line edit widget (default is False)
step [float]: step between tick values with a slider widget (optional)
nonzero [bool]: if True, zero is not a valid value (optional)
unit [string]: physical unit (optional)
help [string]: text shown in tooltip (optional)
check [bool]: if False, value is not checked (optional, default=True)
- type¶
alias of
float
- class guidata.dataset.dataitems.IntItem(label, default=None, min=None, max=None, nonzero=None, unit='', even=None, slider=False, help='', check=True)[source]¶
- Construct an integer data item
label [string]: name
default [int]: default value (optional)
min [int]: minimum value (optional)
max [int]: maximum value (optional)
nonzero [bool]: if True, zero is not a valid value (optional)
unit [string]: physical unit (optional)
even [bool]: if True, even values are valid, if False, odd values are valid if None (default), ignored (optional)
slider [bool]: if True, shows a slider widget right after the line edit widget (default is False)
help [string]: text shown in tooltip (optional)
check [bool]: if False, value is not checked (optional, default=True)
- type¶
alias of
int
- class guidata.dataset.dataitems.StringItem(label, default=None, notempty=None, wordwrap=False, help='')[source]¶
- Construct a string data item
label [string]: name
default [string]: default value (optional)
help [string]: text shown in tooltip (optional)
notempty [bool]: if True, empty string is not a valid value (opt.)
wordwrap [bool]: toggle word wrapping (optional)
- class guidata.dataset.dataitems.TextItem(label, default=None, notempty=None, wordwrap=True, help='')[source]¶
- Construct a text data item (multiline string)
label [string]: name
default [string]: default value (optional)
help [string]: text shown in tooltip (optional)
notempty [bool]: if True, empty string is not a valid value (opt.)
wordwrap [bool]: toggle word wrapping (optional)
- class guidata.dataset.dataitems.BoolItem(text='', label='', default=None, help='', check=True)[source]¶
- Construct a boolean data item
text [string]: form’s field name (optional)
label [string]: name
default [string]: default value (optional)
help [string]: text shown in tooltip (optional)
check [bool]: if False, value is not checked (optional, default=True)
- type¶
alias of
bool
- class guidata.dataset.dataitems.DateItem(label, default=None, help='', check=True)[source]¶
- Construct a date data item.
text [string]: form’s field name (optional)
label [string]: name
default [datetime.date]: default value (optional)
help [string]: text shown in tooltip (optional)
- type¶
alias of
date
- class guidata.dataset.dataitems.ColorItem(label, default=None, notempty=None, wordwrap=False, help='')[source]¶
- Construct a color data item
label [string]: name
default [string]: default value (optional)
help [string]: text shown in tooltip (optional)
check [bool]: if False, value is not checked (optional, default=True)
Color values are encoded as hexadecimal strings or Qt color names
- class guidata.dataset.dataitems.FileSaveItem(label, formats='*', default=None, basedir=None, all_files_first=False, help='', check=True)[source]¶
- Construct a path data item for a file to be saved
label [string]: name
formats [string (or string list)]: wildcard filter
default [string]: default value (optional)
basedir [string]: default base directory (optional)
help [string]: text shown in tooltip (optional)
check [bool]: if False, value is not checked (optional, default=True)
- class guidata.dataset.dataitems.FileOpenItem(label, formats='*', default=None, basedir=None, all_files_first=False, help='', check=True)[source]¶
- Construct a path data item for a file to be opened
label [string]: name
formats [string (or string list)]: wildcard filter
default [string]: default value (optional)
basedir [string]: default base directory (optional)
help [string]: text shown in tooltip (optional)
check [bool]: if False, value is not checked (optional, default=True)
- class guidata.dataset.dataitems.FilesOpenItem(label, formats='*', default=None, basedir=None, all_files_first=False, help='', check=True)[source]¶
- Construct a path data item for multiple files to be opened.
label [string]: name
formats [string (or string list)]: wildcard filter
default [string]: default value (optional)
basedir [string]: default base directory (optional)
help [string]: text shown in tooltip (optional)
check [bool]: if False, value is not checked (optional, default=True)
- type¶
alias of
list
- class guidata.dataset.dataitems.DirectoryItem(label, default=None, notempty=None, wordwrap=False, help='')[source]¶
- Construct a path data item for a directory.
label [string]: name
default [string]: default value (optional)
help [string]: text shown in tooltip (optional)
check [bool]: if False, value is not checked (optional, default=True)
- class guidata.dataset.dataitems.ChoiceItem(label, choices, default=<class 'guidata.dataset.dataitems.FirstChoice'>, help='', check=True, radio=False)[source]¶
- Construct a data item for a list of choices.
label [string]: name
choices [list, tuple or function]: string list or (key, label) list function of two arguments (item, value) returning a list of tuples (key, label, image) where image is an icon path, a QIcon instance or a function of one argument (key) returning a QIcon instance
default [-]: default label or default key (optional)
help [string]: text shown in tooltip (optional)
check [bool]: if False, value is not checked (optional, default=True)
radio [bool]: if True, shows radio buttons instead of a combo box (default is False)
- class guidata.dataset.dataitems.MultipleChoiceItem(label, choices, default=(), help='', check=True)[source]¶
- Construct a data item for a list of choices – multiple choices can be selected
label [string]: name
choices [list or tuple]: string list or (key, label) list
default [-]: default label or default key (optional)
help [string]: text shown in tooltip (optional)
check [bool]: if False, value is not checked (optional, default=True)
- horizontal(row_nb=1)[source]¶
Method to arange choice list horizontally on n rows
Example: nb = MultipleChoiceItem(“Number”, [‘1’, ‘2’, ‘3’] ).horizontal(2)
- class guidata.dataset.dataitems.ImageChoiceItem(label, choices, default=<class 'guidata.dataset.dataitems.FirstChoice'>, help='', check=True, radio=False)[source]¶
- Construct a data item for a list of choices with images
label [string]: name
choices [list, tuple or function]: (label, image) list or (key, label, image) list function of two arguments (item, value) returning a list of tuples (key, label, image) where image is an icon path, a QIcon instance or a function of one argument (key) returning a QIcon instance
default [-]: default label or default key (optional)
help [string]: text shown in tooltip (optional)
check [bool]: if False, value is not checked (optional, default=True)
- class guidata.dataset.dataitems.FloatArrayItem(label, default=None, help='', format='%.3f', transpose=False, minmax='all', check=True)[source]¶
- Construct a float array data item
label [string]: name
default [numpy.ndarray]: default value (optional)
help [string]: text shown in tooltip (optional)
format [string]: formatting string (example: ‘%.3f’) (optional)
transpose [bool]: transpose matrix (display only)
large [bool]: view all float of the array
minmax [string]: “all” (default), “columns”, “rows”
check [bool]: if False, value is not checked (optional, default=True)
- class guidata.dataset.dataitems.ButtonItem(label, callback, icon=None, default=None, help='', check=True)[source]¶
- Construct a simple button that calls a method when hit
label [string]: text shown on the button
- callback [function]: function with four parameters (dataset, item, value, parent)
dataset [DataSet]: instance of the parent dataset
item [DataItem]: instance of ButtonItem (i.e. self)
value [unspecified]: value of ButtonItem (default ButtonItem value or last value returned by the callback)
parent [QObject]: button’s parent widget
icon [QIcon or string]: icon show on the button (optional) (string: icon filename as in guidata/guiqwt image search paths)
default [unspecified]: default value passed to the callback (optional)
help [string]: text shown in button’s tooltip (optional)
check [bool]: if False, value is not checked (optional, default=True)
The value of this item is unspecified but is passed to the callback along with the whole dataset. The value is assigned the callback`s return value.
- class guidata.dataset.dataitems.DictItem(label, default=None, help='', check=True)[source]¶
- Construct a dictionary data item
label [string]: name
default [dict]: default value (optional)
help [string]: text shown in tooltip (optional)
check [bool]: if False, value is not checked (optional, default=True)
- class guidata.dataset.dataitems.FontFamilyItem(label, default=None, notempty=None, wordwrap=False, help='')[source]¶
- Construct a font family name item
label [string]: name
default [string]: default value (optional)
help [string]: text shown in tooltip (optional)
dataset.datatypes¶
The guidata.dataset.datatypes
module contains implementation for
DataSets (DataSet, DataSetGroup, …) and related objects (ItemProperty,
ValueProp, …).
- class guidata.dataset.datatypes.FormatProp(fmt, ignore_error=True)[source]¶
A Property that returns a string to help custom read-only representation of items
- class guidata.dataset.datatypes.GetAttrProp(attr)[source]¶
A property that matches the value of an instance’s attribute
- class guidata.dataset.datatypes.ValueProp(value)[source]¶
A property that retrieves a value stored elsewhere
- class guidata.dataset.datatypes.FuncProp(prop, func, invfunc=None)[source]¶
An ‘operator property’ prop: ItemProperty instance func: function invfunc: inverse function (optional)
- class guidata.dataset.datatypes.DataItem(label, default=None, help='', check=True)[source]¶
DataSet data item
label : string default : any type, optional help : string Text displayed on data item’s tooltip
- get_prop(realm, name, default=<class 'guidata.dataset.datatypes.NoDefault'>)[source]¶
Get one property of this item
- set_prop(realm, **kwargs)[source]¶
Set one or several properties using the syntax set_prop(name1=value1, …, nameX=valueX)
it returns self so that we can assign to the result like this:
item = Item().set_prop(x=y)
- format_string(instance, value, fmt, func)[source]¶
Apply format to string representation of the item’s value
- get_string_value(instance)[source]¶
Return a formatted unicode representation of the item’s value obeying ‘display’ or ‘repr’ properties
- accept(visitor)[source]¶
This is the visitor pattern’s accept function. It calls the corresponding visit_MYCLASS method of the visitor object.
Python’s allow a generic base class implementation of this method so there’s no need to write an accept function for each derived class unless you need to override the default behavior
- serialize(instance, writer)[source]¶
Serialize this item using the writer object
this is a default implementation that should work for everything but new datatypes
- class guidata.dataset.datatypes.Obj(**kwargs)[source]¶
An object that helps build default instances for ObjectItems
- class guidata.dataset.datatypes.ObjectItem(label, default=None, help='', check=True)[source]¶
Simple helper class implementing default for composite objects
- class guidata.dataset.datatypes.DataItemProxy(item)[source]¶
Proxy for DataItem objects
This class is needed to construct GroupItem class (see module guidata.qtwidgets)
- get_prop(realm, name, default=<class 'guidata.dataset.datatypes.NoDefault'>)[source]¶
DataItem method proxy
- class guidata.dataset.datatypes.DataItemVariable(item, instance)[source]¶
An instance of a DataItemVariable represent a binding between an item and a dataset.
could be called a bound property.
since DataItem instances are class attributes they need to have a DataSet instance to store their value. This class binds the two together.
- get_prop_value(realm, name, default=<class 'guidata.dataset.datatypes.NoDefault'>)[source]¶
DataItem method proxy
- get_prop(realm, name, default=<class 'guidata.dataset.datatypes.NoDefault'>)[source]¶
DataItem method proxy
- class guidata.dataset.datatypes.DataSetMeta(name, bases, dct)[source]¶
DataSet metaclass
Create class attribute _items: list of the DataSet class attributes, created in the same order as these attributes were written
- class guidata.dataset.datatypes.DataSet(title=None, comment=None, icon='')[source]¶
- Construct a DataSet object is a set of DataItem objects
title [string]
comment [string]: text shown on the top of the first data item
icon [QIcon or string]: icon show on the button (optional) (string: icon filename as in guidata/guiqwt image search paths)
- edit(parent=None, apply=None, size=None)[source]¶
- Open a dialog box to edit data set
parent: parent widget (default is None, meaning no parent)
apply: apply callback (default is None)
size: dialog size (QSize object or integer tuple (width, height))
- view(parent=None, size=None)[source]¶
- Open a dialog box to view data set
parent: parent widget (default is None, meaning no parent)
size: dialog size (QSize object or integer tuple (width, height))
- class guidata.dataset.datatypes.ActivableDataSet(title=None, comment=None, icon='')[source]¶
An ActivableDataSet instance must have an “enable” class attribute which will set the active state of the dataset instance (see example in: tests/activable_dataset.py)
- class guidata.dataset.datatypes.DataSetGroup(datasets, title=None, icon='')[source]¶
- Construct a DataSetGroup object, used to group several datasets together
datasets [list of DataSet objects]
title [string]
icon [QIcon or string]: icon show on the button (optional) (string: icon filename as in guidata/guiqwt image search paths)
This class tries to mimics the DataSet interface.
The GUI should represent it as a notebook with one page for each contained dataset.
- class guidata.dataset.datatypes.BeginGroup(label, default=None, help='', check=True)[source]¶
Data item which does not represent anything but a begin flag to define a data set group
- class guidata.dataset.datatypes.EndGroup(label, default=None, help='', check=True)[source]¶
Data item which does not represent anything but an end flag to define a data set group
dataset.qtitemwidgets¶
Widget factories used to edit data items (factory registration is done in guidata.dataset.qtwidgets) (data item types are defined in guidata.dataset.datatypes)
There is one widget type for each data item type. Example: ChoiceWidget <–> ChoiceItem, ImageChoiceItem
- class guidata.dataset.qtitemwidgets.AbstractDataSetWidget(item, parent_layout)[source]¶
Base class for ‘widgets’ handled by DataSetEditLayout and it’s derived classes.
This is a generic representation of an input (or display) widget that has a label and one or more entry field.
DataSetEditLayout uses a registry of Item to Widget mapping in order to automatically create a GUI for a DataSet structure
- place_label(layout, row, column)[source]¶
Place item label on layout at specified position (row, column)
- class guidata.dataset.qtitemwidgets.LineEditWidget(item, parent_layout)[source]¶
QLineEdit-based widget
- class guidata.dataset.qtitemwidgets.TextEditWidget(item, parent_layout)[source]¶
QTextEdit-based widget
- class guidata.dataset.qtitemwidgets.DateTimeWidget(item, parent_layout)[source]¶
DateTimeItem widget
- class guidata.dataset.qtitemwidgets.GroupLayout[source]¶
- class guidata.dataset.qtitemwidgets.SliderWidget(item, parent_layout)[source]¶
IntItem with Slider
- DATA_TYPE¶
alias of
int
- class guidata.dataset.qtitemwidgets.FloatSliderWidget(item, parent_layout)[source]¶
FloatItem with Slider
- DATA_TYPE¶
alias of
float
- class guidata.dataset.qtitemwidgets.FileWidget(item, parent_layout, filedialog)[source]¶
File path item widget
- class guidata.dataset.qtitemwidgets.DirectoryWidget(item, parent_layout)[source]¶
Directory path item widget
- class guidata.dataset.qtitemwidgets.MultipleChoiceWidget(item, parent_layout)[source]¶
Multiple choice item widget
- class guidata.dataset.qtitemwidgets.FloatArrayWidget(item, parent_layout)[source]¶
FloatArrayItem widget
- class guidata.dataset.qtitemwidgets.DataSetWidget(item, parent_layout)[source]¶
DataSet widget
- get_dataset()[source]¶
update’s internal parameter representation from the item’s stored value
default behavior uses update_dataset and assumes internal dataset class is the same as item’s value class
dataset.qtwidgets¶
- Dialog boxes used to edit data sets:
DataSetEditDialog DataSetGroupEditDialog DataSetShowDialog
- …and layouts:
GroupItem DataSetEditLayout DataSetShowLayout
- class guidata.dataset.qtwidgets.DataSetEditDialog(instance, icon='', parent=None, apply=None, wordwrap=True, size=None)[source]¶
Dialog box for DataSet editing
- class guidata.dataset.qtwidgets.DataSetGroupEditDialog(instance, icon='', parent=None, apply=None, wordwrap=True, size=None)[source]¶
Tabbed dialog box for DataSet editing
- class guidata.dataset.qtwidgets.DataSetEditLayout(parent, instance, layout, items=None, first_line=0, change_callback=None)[source]¶
Layout in which data item widgets are placed
- class guidata.dataset.qtwidgets.DataSetShowWidget(item, parent_layout)[source]¶
Read-only base widget
- class guidata.dataset.qtwidgets.ShowColorWidget(item, parent_layout)[source]¶
Read-only color item widget
- class guidata.dataset.qtwidgets.ShowBooleanWidget(item, parent_layout)[source]¶
Read-only bool item widget
- class guidata.dataset.qtwidgets.DataSetShowLayout(parent, instance, layout, items=None, first_line=0, change_callback=None)[source]¶
Read-only layout
- class guidata.dataset.qtwidgets.DataSetShowDialog(instance, icon='', parent=None, apply=None, wordwrap=True, size=None)[source]¶
Read-only dialog box
- class guidata.dataset.qtwidgets.DataSetShowGroupBox(label, klass, wordwrap=False, **kwargs)[source]¶
Group box widget showing a read-only DataSet
- class guidata.dataset.qtwidgets.DataSetEditGroupBox(label, klass, button_text=None, button_icon=None, show_button=True, wordwrap=False, **kwargs)[source]¶
Group box widget including a DataSet
label: group box label (string) klass: guidata.DataSet class button_text: action button text (default: “Apply”) button_icon: QIcon object or string (default “apply.png”)
- SIG_APPLY_BUTTON_CLICKED¶
Signal emitted when Apply button is clicked