mcsas.gui.bases.datalist module

class DataItem(data)[source]

Bases: QTreeWidgetItem

Generates a QTreeWidgetItem from arbitrary python objects. Storing those objects separately.

data(*args)[source]

Warning

method ‘gui.bases.datalist.DataItem.data’ undocumented

dataId()[source]

Warning

method ‘gui.bases.datalist.DataItem.dataId’ undocumented

getItemProperty(value)[source]

For a value, returns this items getter/setter methods according to value type.

static hash32(data)[source]

Avoids OverFlowError at setData() with PySide on MacOS.

isRemovable
isTopLevelItem()[source]

Warning

method ‘gui.bases.datalist.DataItem.isTopLevelItem’ undocumented

listIndex()[source]

Index of this items top most parent in the treewidget.

remove()[source]

Removes the item from its treewidget or parent item.

setAlignment(alignment)[source]

Warning

method ‘gui.bases.datalist.DataItem.setAlignment’ undocumented

setChanged(column)[source]

Warning

method ‘gui.bases.datalist.DataItem.setChanged’ undocumented

setClicked(column)[source]

Warning

method ‘gui.bases.datalist.DataItem.setClicked’ undocumented

update()[source]

Updates this item according to eventually changed data object

wasClickedAndChanged()[source]

Tests if this item was previously clicked and changed in the UI.

class DataList(parent=None, title=None, withBtn=True, nestedItems=True)[source]

Bases: QWidget, gui.bases.mixins.dropwidget.DropWidget, gui.bases.mixins.contextmenuwidget.ContextMenuWidget

Manages all loaded spectra.

>>> from utilsgui import DialogInteraction, DisplayException
>>> from spectralist import SpectraList
>>> sl = DialogInteraction.instance(SpectraList)

Test available actions >>> [str(action.text()) for action in sl.listWidget.actions()] [‘load spectra’, ‘remove’, ‘’, ‘save matrices’, ‘select all’] >>> sl.listWidget.count() 0

Test methods on empty list >>> sl.updateSpectra() >>> sl.removeSelectedSpectra() >>> [sl.getMatrix(i) for i in -1,0,1] [None, None, None] >>> DialogInteraction.query(DisplayException, sl.saveMatrix, ... slot = ‘accept’) >>> sl.selectionChangedSlot()

add(data)[source]

Warning

method ‘gui.bases.datalist.DataList.add’ undocumented

clear()[source]

Warning

method ‘gui.bases.datalist.DataList.clear’ undocumented

currentSelection()[source]

Warning

method ‘gui.bases.datalist.DataList.currentSelection’ undocumented

data(indexOrItem=None, selectedOnly=False)[source]

Returns the list of data for a given list index or list widget item. If none is specified return the data of all items or the data of selected items only, if desired.

expandAll()[source]

Warning

method ‘gui.bases.datalist.DataList.expandAll’ undocumented

fitColumnsToContents(*args)[source]

Warning

method ‘gui.bases.datalist.DataList.fitColumnsToContents’ undocumented

hasSelection()[source]

Warning

method ‘gui.bases.datalist.DataList.hasSelection’ undocumented

isEmpty()[source]

Warning

method ‘gui.bases.datalist.DataList.isEmpty’ undocumented

isNotEmpty()[source]

Warning

method ‘gui.bases.datalist.DataList.isNotEmpty’ undocumented

isRemovableSelected()[source]

True, if there is at least one item selected which may be removed

itemDoubleClicked(item, column)[source]

Warning

method ‘gui.bases.datalist.DataList.itemDoubleClicked’ undocumented

itemUpdate(item, column)[source]

Reimplement to update item if changed by user in GUI

itemsHaveChildren()[source]

Warning

method ‘gui.bases.datalist.DataList.itemsHaveChildren’ undocumented

leaveEvent(event)[source]

Warning

method ‘gui.bases.datalist.DataList.leaveEvent’ undocumented

loadData(sourceList=None, processSourceFunc=None, showProgress=True, alignment=None, **kwargs)[source]

Loads a list of data source items.

processSourceFunc is expected to be a function which gets individual elements of sourceList as argument. It returns an arbitrary data item which is then added to this data list widget.

Reimplement it in child classes and it will be called on load button and add action signal.

This method handles exceptions and progress indication.

Test loading a single spectra >>> import utils >>> from tests import TestData >>> from utilsgui import DialogInteraction, UiSettings, fileDialogType >>> from chemsettings import ChemSettings >>> from datafiltersgui import DataFiltersGui >>> from spectralist import SpectraList >>> cs = DialogInteraction.instance(ChemSettings) >>> dfg = DialogInteraction.instance(DataFiltersGui) >>> sl = DialogInteraction.instance(SpectraList, settings = cs) >>> utils.LastPath.path = TestData.spectra(0) >>> DialogInteraction.query(fileDialogType(), sl.loadData, ... slot = ‘accept’) >>> sl.updateSpectra() >>> utils.LastPath.path = utils.getTempFileName() >>> matrixfiles = DialogInteraction.query(fileDialogType(), sl.saveMatrix, ... slot = ‘accept’) >>> len(matrixfiles) 1 >>> matrixfiles

Verify written matrix data with existent matrix export >>> TestData.verifyMatrix(TestData.spectra(0), ... matrixfiles[0]) True

removeItems(indexList)[source]

Deletes items specified in the given list of indices.

removeSelected()[source]

Warning

method ‘gui.bases.datalist.DataList.removeSelected’ undocumented

reraiseLast()[source]

Reraise the last error if any and display an error message dialog.

selectAll()[source]

Selects all items in the list if not all are selected. Clears the selection if all items in the list already are selected.

selectionChanged()[source]

Warning

method ‘gui.bases.datalist.DataList.selectionChanged’ undocumented

setCurrentIndex(index)[source]

Warning

method ‘gui.bases.datalist.DataList.setCurrentIndex’ undocumented

setHeader(labels=None)[source]

Warning

method ‘gui.bases.datalist.DataList.setHeader’ undocumented

setupUi()[source]

Reimplement this in child classes for custom UI configuration.

sigEditingFinished
sigEmpty
sigReceivedUrls
sigRemovedData
sigSelectedData
sigUpdatedData
topLevelItems()[source]

Warning

method ‘gui.bases.datalist.DataList.topLevelItems’ undocumented

updateData(selectedOnly=False, showProgress=True, updateFunc=None, prepareFunc=None, stopFunc=None, **kwargs)[source]

Calls the provided function on all data items.

The object returned by prepareFunc() is forwarded as optional argument to updateFunc(dataItem, optionalArguments = None).

updateItems()[source]

Warning

method ‘gui.bases.datalist.DataList.updateItems’ undocumented