Data items¶
Base class¶
Numeric items¶
- class guidata.dataset.dataitems.FloatItem(label: str, default: float | None = None, min: float | None = None, max: float | None = None, nonzero: bool | None = None, unit: str = '', step: float = 0.1, slider: bool = False, help: str = '', check: bool = True)¶
Construct a float data item
- Parameters:
label (str) – item name
default (float) – default value (optional)
min (float) – minimum value (optional)
max (float) – maximum value (optional)
nonzero (bool) – if True, zero is not a valid value (optional)
unit (str) – 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 (str) – text shown in tooltip (optional)
check (bool) – if False, value is not checked (optional, default=True)
- get_value_from_reader(reader: HDF5Reader | JSONReader | INIReader) float ¶
Reads value from the reader object, inside the try…except statement defined in the base item deserialize method
- class guidata.dataset.dataitems.IntItem(label: str, default: int | None = None, min: int | None = None, max: int | None = None, nonzero: bool | None = None, unit: str = '', even: bool | None = None, slider: bool = False, help: str = '', check: bool = True)¶
Construct an integer data item
- Parameters:
label (str) – item 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 (str) – 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 (str) – text shown in tooltip (optional)
check (bool) – if False, value is not checked (optional, default=True)
- get_value_from_reader(reader: HDF5Reader | JSONReader | INIReader) Any ¶
Reads value from the reader object, inside the try…except statement defined in the base item deserialize method
- class guidata.dataset.dataitems.FloatArrayItem(label: str, default: numpy.ndarray | None = None, help: str = '', format: str = '%.3f', transpose: bool = False, minmax: str = 'all', check: bool = True)¶
Construct a float array data item
- Parameters:
label (str) – item name
default (numpy.ndarray) – default value (optional)
help (str) – text shown in tooltip (optional)
format (str) – formatting string (example: ‘%.3f’) (optional)
transpose (bool) – transpose matrix (display only)
large (bool) – view all float of the array
minmax (str) – “all” (default), “columns”, “rows”
check (bool) – if False, value is not checked (optional, default=True)
- format_string(instance: DataSet, value: Any, fmt: str, func: Callable) str ¶
Override DataItem method
- serialize(instance: DataSet, writer: HDF5Writer | JSONWriter | INIWriter) None ¶
Serialize this item
- get_value_from_reader(reader: HDF5Reader | JSONReader | INIReader) Any ¶
Reads value from the reader object, inside the try…except statement defined in the base item deserialize method
Text items¶
- class guidata.dataset.dataitems.StringItem(label: str, default: str | None = None, notempty: bool | None = None, wordwrap: bool = False, help: str = '')¶
Construct a string data item
- Parameters:
- get_value_from_reader(reader: HDF5Reader | JSONReader | INIReader) Any ¶
Reads value from the reader object, inside the try…except statement defined in the base item deserialize method
Date and time items¶
- class guidata.dataset.dataitems.DateItem(label: str, default: datetime.date | None = None, format: str | None = None, help: str | None = '', check: bool | None = True)¶
DataSet data item
- Parameters:
label (str) – item label
default (datetime.date) – default value (optional)
format (str) – date format (as in
datetime.date.strftime()
)help (str) – text displayed on data item’s tooltip
check (bool) – check value (default: True)
- class guidata.dataset.dataitems.DateTimeItem(label: str, default: datetime.date | None = None, format: str | None = None, help: str | None = '', check: bool | None = True)¶
DataSet data item
- Parameters:
label (str) – item label
default (datetime.datetime) – default value (optional)
format (str) – date format (as in
datetime.date.strftime()
)help (str) – text displayed on data item’s tooltip
check (bool) – check value (default: True)
Color items¶
- class guidata.dataset.dataitems.ColorItem(label: str, default: str | None = None, notempty: bool | None = None, wordwrap: bool = False, help: str = '')¶
Construct a color data item
- Parameters:
- get_value_from_reader(reader: HDF5Reader | JSONReader | INIReader) str ¶
Reads value from the reader object, inside the try…except statement defined in the base item deserialize method
File items¶
- class guidata.dataset.dataitems.FileSaveItem(label: str, formats: tuple[str, ...] | str = '*', default: list[str] | str | None = None, basedir: str | None = None, all_files_first: bool = False, help: str = '', check: bool = True)¶
Construct a path data item for a file to be saved
- Parameters:
- class guidata.dataset.dataitems.FileOpenItem(label: str, formats: tuple[str, ...] | str = '*', default: list[str] | str | None = None, basedir: str | None = None, all_files_first: bool = False, help: str = '', check: bool = True)¶
Construct a path data item for a file to be opened
- Parameters:
- class guidata.dataset.dataitems.FilesOpenItem(label: str, formats: str = '*', default: list[str] | str | None = None, basedir: str | None = None, all_files_first: bool = False, help: str = '', check: bool = True)¶
Construct a path data item for multiple files to be opened.
- Parameters:
- serialize(instance: DataSet, writer: HDF5Writer | JSONWriter | INIWriter) None ¶
Serialize this item
- get_value_from_reader(reader: HDF5Reader | JSONReader | INIReader) list[str] ¶
Reads value from the reader object, inside the try…except statement defined in the base item deserialize method
Choice items¶
- class guidata.dataset.dataitems.BoolItem(text: str = '', label: str = '', default: bool | None = None, help: str = '', check: bool = True)¶
Construct a boolean data item
- Parameters:
- get_value_from_reader(reader: HDF5Reader | JSONReader | INIReader) bool ¶
Reads value from the reader object, inside the try…except statement defined in the base item deserialize method
- class guidata.dataset.dataitems.ChoiceItem(label: str, choices: ~typing.Any, default: tuple[()] | type[guidata.dataset.dataitems.FirstChoice] | int | None = <class 'guidata.dataset.dataitems.FirstChoice'>, help: str = '', check: bool = True, radio: bool = False)¶
Construct a data item for a list of choices.
- Parameters:
label (str) – item name
choices (list, tuple or Callable) – 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 (str) – default value (optional)
help (str) – 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: str, choices: list[str], default: tuple[()] = (), help: str = '', check: bool = True)¶
Construct a data item for a list of choices – multiple choices can be selected
- Parameters:
- horizontal(row_nb: int = 1) MultipleChoiceItem ¶
Method to arange choice list horizontally on n rows
Example: nb = MultipleChoiceItem(“Number”, [‘1’, ‘2’, ‘3’] ).horizontal(2)
- vertical(col_nb: int = 1) MultipleChoiceItem ¶
Method to arange choice list vertically on n columns
Example: nb = MultipleChoiceItem(“Number”, [‘1’, ‘2’, ‘3’] ).vertical(2)
- serialize(instance: DataSet, writer: HDF5Writer | JSONWriter | INIWriter) None ¶
Serialize this item
- deserialize(instance: DataSet, reader: HDF5Reader | JSONReader | INIReader) None ¶
Deserialize this item
- class guidata.dataset.dataitems.ImageChoiceItem(label: str, choices: ~typing.Any, default: tuple[()] | type[guidata.dataset.dataitems.FirstChoice] | int | None = <class 'guidata.dataset.dataitems.FirstChoice'>, help: str = '', check: bool = True, radio: bool = False)¶
Construct a data item for a list of choices with images
- Parameters:
label (str) – item name
choices (list or tuple) – (label, image) list, or (key, label, image) list, or 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 (str) – default value (optional)
help (str) – text shown in tooltip (optional)
check (bool) – if False, value is not checked (optional, default=True)
Other items¶
- class guidata.dataset.dataitems.ButtonItem(label: str, callback: Callable, icon: str | None = None, default: Any | None = None, help: str = '', check: bool = True)¶
Construct a simple button that calls a method when hit
- Parameters:
label (str) – item name
callback (Callable) – function with four parameters (dataset, item, value, parent) where dataset (DataSet) is an instance of the parent dataset, item (DataItem) is an instance of ButtonItem (i.e. self), value (unspecified) is the value of ButtonItem (default ButtonItem value or last value returned by the callback) and parent (QObject) is button’s parent widget
icon (QIcon or str) – icon show on the button (optional) (str: icon filename as in guidata/guiqwt image search paths)
default (Any) – default value passed to the callback (optional)
help (str) – 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.
- serialize(instance: DataSet, writer: HDF5Writer | JSONWriter | INIWriter) Any ¶
Serialize this item using the writer object
This is a default implementation that should work for everything but new datatypes
- Parameters:
instance (DataSet) – instance of the DataSet
writer (HDF5Writer | JSONWriter | INIWriter) – writer object
- deserialize(instance: DataSet, reader: HDF5Reader | JSONReader | INIReader) Any ¶
Deserialize this item using the reader object
Default base implementation supposes the reader can detect expected datatype from the stream
- Parameters:
instance (Any) – instance of the DataSet
reader (HDF5Reader | JSONReader | INIReader) – reader object
- class guidata.dataset.dataitems.DictItem(label: str, default: dict | None = None, help: str = '', check: bool = True)¶
Construct a dictionary data item