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=u'', help=u'', check=True)[source]¶ Numeric data item
-
class
guidata.dataset.dataitems.
FloatItem
(label, default=None, min=None, max=None, nonzero=None, unit=u'', step=0.1, slider=False, help=u'', 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=u'', even=None, slider=False, help=u'', 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=u'')[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=u'')[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=u'', label=u'', default=None, help=u'', 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=u'', 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=u'')[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=u'*', default=None, basedir=None, all_files_first=False, help=u'', 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=u'*', default=None, basedir=None, all_files_first=False, help=u'', 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=u'*', default=None, basedir=None, all_files_first=False, help=u'', 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=u'')[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=u'', 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=u'', 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=u'', 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=u'', format=u'%.3f', transpose=False, minmax=u'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=u'', 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=u'', 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)
dataset.datatypes¶
The guidata.dataset.datatypes
module contains implementation for
DataSets (DataSet, DataSetGroup, ...) and related objects (ItemProperty,
ValueProp, ...).
-
class
guidata.dataset.datatypes.
ActivableDataSet
(title=None, comment=None, icon=u'')[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.
BeginGroup
(label, default=None, help=u'', check=True)[source]¶ Data item which does not represent anything but a begin flag to define a data set group
-
class
guidata.dataset.datatypes.
DataItem
(label, default=None, help=u'', check=True)[source]¶ DataSet data item
label : string default : any type, optional help : string Text displayed on data item’s tooltip
-
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
-
deserialize
(instance, reader)[source]¶ Deserialize this item using the reader object
Default base implementation supposes the reader can detect expected datatype from the stream
-
format_string
(instance, value, fmt, func)[source]¶ Apply format to string representation of the item’s value
-
get_prop
(realm, name, default=<class guidata.dataset.datatypes.NoDefault>)[source]¶ Get one property of this item
-
get_string_value
(instance)[source]¶ Return a formatted unicode representation of the item’s value obeying ‘display’ or ‘repr’ properties
-
get_value_from_reader
(reader)[source]¶ Reads value from the reader object, inside the try...except statement defined in the base item deserialize method
This method is reimplemented in some child classes
-
-
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
(realm, name, default=<class guidata.dataset.datatypes.NoDefault>)[source]¶ DataItem method proxy
-
get_prop_value
(realm, name, default=<class guidata.dataset.datatypes.NoDefault>)[source]¶ DataItem method proxy
-
-
class
guidata.dataset.datatypes.
DataSet
(title=None, comment=None, icon=u'')[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)
-
accept
(vis)[source]¶ helper function that passes the visitor to the accept methods of all the items in this dataset
-
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))
-
class
guidata.dataset.datatypes.
DataSetGroup
(datasets, title=None, icon=u'')[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.
DataSetMeta
[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.
EndGroup
(label, default=None, help=u'', check=True)[source]¶ Data item which does not represent anything but an end flag to define a data set group
-
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.
FuncProp
(prop, func, invfunc=None)[source]¶ An ‘operator property’ prop: ItemProperty instance func: function invfunc: inverse function (optional)
-
class
guidata.dataset.datatypes.
GetAttrProp
(attr)[source]¶ A property that matches the value of an instance’s attribute
-
class
guidata.dataset.datatypes.
Obj
(**kwargs)[source]¶ An object that helps build default instances for ObjectItems
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.
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)[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)[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
-