Data sets

Defining data sets

class guidata.dataset.datatypes.DataSet(title: Optional[str] = None, comment: Optional[str] = None, icon: str = '')
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)

classmethod create(**kwargs) DataSet

Create a new instance of the DataSet class

Parameters:

**kwargs – keyword arguments to set the DataItem values

Returns:

DataSet instance

get_title() str

Return data set title

get_comment() Optional[str]

Return data set comment

get_icon() Optional[str]

Return data set icon

set_defaults() None

Set default values

check() List[str]

Check the dataset item values

text_edit() None

Edit data set with text input only

edit(parent: Optional[QWidget] = None, apply: Optional[Callable] = None, size: Optional[Any] = None) DataSetEditDialog
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: Optional[QWidget] = None, size: Optional[Any] = None)
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))

to_string(debug: Optional[bool] = False, indent: Optional[str] = None, align: Optional[bool] = False, show_hidden: Optional[bool] = True)

Return readable string representation of the data set If debug is True, add more details on data items

accept(vis: object) None

helper function that passes the visitor to the accept methods of all the items in this dataset

class guidata.dataset.datatypes.DataSetGroup(datasets: List[DataSet], title: Optional[str] = None, icon: str = '')
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.

get_title() str

Return data set group title

get_comment() None

Return data set group comment –> not implemented (will return None)

get_icon() Optional[str]

Return data set icon

check() List[List[str]]

Check data set group items

text_edit() None

Edit data set with text input only

edit(parent: Optional[QWidget] = None, apply: Optional[Callable] = None) int

Open a dialog box to edit data set

accept(vis: object) None

helper function that passes the visitor to the accept methods of all the items in this dataset

class guidata.dataset.datatypes.ActivableDataSet(title: Optional[str] = None, comment: Optional[str] = None, icon: str = '')

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)

classmethod active_setup() None

This class method must be called after the child class definition in order to setup the dataset active state

set_readonly() None

The dataset is now in read-only mode, i.e. all data items are disabled

set_writeable() None

The dataset is now in read/write mode, i.e. all data items are enabled

Grouping items

class guidata.dataset.datatypes.BeginGroup(label: str, default: Optional[Any] = None, help: Optional[str] = '', check: Optional[bool] = True)

Data item which does not represent anything but a begin flag to define a data set group

serialize(instance, writer) None

Serialize this item using the writer object

this is a default implementation that should work for everything but new datatypes

deserialize(instance, reader) None

Deserialize this item using the reader object

Default base implementation supposes the reader can detect expected datatype from the stream

class guidata.dataset.datatypes.EndGroup(label: str, default: Optional[Any] = None, help: Optional[str] = '', check: Optional[bool] = True)

Data item which does not represent anything but an end flag to define a data set group

serialize(instance, writer) None

Serialize this item using the writer object

this is a default implementation that should work for everything but new datatypes

deserialize(instance, reader) None

Deserialize this item using the reader object

Default base implementation supposes the reader can detect expected datatype from the stream

class guidata.dataset.datatypes.BeginTabGroup(label: str, default: Optional[Any] = None, help: Optional[str] = '', check: Optional[bool] = True)
class guidata.dataset.datatypes.EndTabGroup(label: str, default: Optional[Any] = None, help: Optional[str] = '', check: Optional[bool] = True)

Handling item properties

class guidata.dataset.datatypes.FormatProp(fmt: str, ignore_error: Optional[bool] = True)

A Property that returns a string to help custom read-only representation of items

class guidata.dataset.datatypes.GetAttrProp(attr: str)

A property that matches the value of an instance’s attribute

set(instance: DataSet, item: DataItem, value: Any) None

Sets the value of the property given an instance, item and value Depending on implementation the value will be stored either on the instance, item or self

class guidata.dataset.datatypes.ValueProp(value: Any)

A property that retrieves a value stored elsewhere

set(instance: DataSet, item: DataItem, value: Any) None

Sets the value of the property given an instance, item and value Depending on implementation the value will be stored either on the instance, item or self

class guidata.dataset.datatypes.NotProp(prop: ItemProperty)

Not property

set(instance: DataSet, item: DataItem, value: Any) None

Sets the value of the property given an instance, item and value Depending on implementation the value will be stored either on the instance, item or self

class guidata.dataset.datatypes.FuncProp(prop: ItemProperty, func: Callable, invfunc: Optional[Callable] = None)

An ‘operator property’ prop: ItemProperty instance func: function invfunc: inverse function (optional)

set(instance: DataSet, item: DataItem, value: Any) None

Sets the value of the property given an instance, item and value Depending on implementation the value will be stored either on the instance, item or self