Commit b9b55f81 authored by payno's avatar payno
Browse files

[orangecontrib] rework the display for ft and kweight. kWeight is displaying...

[orangecontrib] rework the display for ft and kweight. kWeight is displaying nothing for the time beeing.

Everything is displayed by ft througt to 'spectrum' display: the window and the ftintensity
parent 4da4f847
......@@ -37,7 +37,10 @@ _logger = logging.getLogger(__file__)
class _PyMcaProcessForOrangeMixIn(object):
"""
Group processing and progress display in a common class for pymca process
Group processing and progress display in a common class for pymca process.
If this process own a widget to display the xas object then this one should
be named '_window'
"""
def __init__(self):
# progress
......@@ -49,11 +52,13 @@ class _PyMcaProcessForOrangeMixIn(object):
self._progress = gui.ProgressBar(self, 100)
def _startProcess(self):
self._window.setEnabled(False)
if hasattr(self, '_window'):
self._window.setEnabled(False)
self._progress.widget.progressBarInit()
def _endProcess(self, xas_obj):
self._window.setEnabled(True)
if hasattr(self, '_window'):
self._window.setEnabled(True)
if self._callback_finish:
try:
self.getProcessingThread()._process_obj._advancement.sigProgress.disconnect(self._setProgressValue)
......@@ -65,7 +70,8 @@ class _PyMcaProcessForOrangeMixIn(object):
if xas_obj is None:
return
else:
self._window.xasObjViewer.setXASObj(xas_obj=xas_obj)
if hasattr(self, '_window') and hasattr(self._window, 'xasObjViewer'):
self._window.xasObjViewer.setXASObj(xas_obj=xas_obj)
# emit signal for the plot
self.send("spectra", xas_obj)
......
......@@ -101,8 +101,8 @@ class ExafsWindow(qt.QMainWindow):
mapKeys = ['Mu', 'EXAFS/EXAFSKValues', 'EXAFS/EXAFSSignal',
'EXAFS/PostEdgeB']
self.xasObjViewer = XasObjectViewer(mapKeys=mapKeys)
self.xasObjViewer._spectrumView._plot.getXAxis().setLabel("K")
self.xasObjViewer._spectrumView._plot.getYAxis().setLabel("Normalized Units")
self.xasObjViewer._spectrumViews[0]._plot.getXAxis().setLabel("K")
self.xasObjViewer._spectrumViews[0]._plot.getYAxis().setLabel("Normalized Units")
self.setCentralWidget(self.xasObjViewer)
# pymca window
......@@ -116,7 +116,7 @@ class ExafsWindow(qt.QMainWindow):
# legend selector
self.legendDockWidget = LegendSelector.LegendsDockWidget(parent=self,
plot=self.xasObjViewer._spectrumView._plot)
plot=self.xasObjViewer._spectrumViews[0]._plot)
self.legendDockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
self.legendDockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
self.addDockWidget(qt.Qt.RightDockWidgetArea, self.legendDockWidget)
......@@ -127,7 +127,7 @@ class ExafsWindow(qt.QMainWindow):
# plot settings
for ope in (_exafs_signal_plot, _exafs_postedge_plot, _exafs_knots_plot,):
self.xasObjViewer._spectrumView.addCurveOperation(ope)
self.xasObjViewer._spectrumViews[0].addCurveOperation(ope)
self.setWindowFlags(qt.Qt.Widget)
......@@ -141,8 +141,9 @@ class ExafsWindow(qt.QMainWindow):
return len(self.xasObjViewer.getAllCurves())
def _updateLegendView(self):
self.legendDockWidget.setVisible(self.xasObjViewer.getViewType() is ViewType.spectrum)
self.xasObjViewer._mapView.keySelectionDocker.setVisible(self.xasObjViewer.getViewType() is ViewType.map)
index, viewType = self.xasObjViewer.getViewType()
self.legendDockWidget.setVisible(viewType is ViewType.spectrum)
self.xasObjViewer._mapView.keySelectionDocker.setVisible(viewType is ViewType.map)
class ExafsOW(_PyMcaProcessForOrangeMixIn, OWWidget):
......@@ -175,8 +176,8 @@ class ExafsOW(_PyMcaProcessForOrangeMixIn, OWWidget):
layout = gui.vBox(self.mainArea, 'fourier transform').layout()
layout.addWidget(self._window)
self._window.xasObjViewer._spectrumView._plot.getXAxis().setLabel("K")
self._window.xasObjViewer._spectrumView._plot.getYAxis().setLabel("Normalized Units")
self._window.xasObjViewer._spectrumViews[0]._plot.getXAxis().setLabel("K")
self._window.xasObjViewer._spectrumViews[0]._plot.getYAxis().setLabel("Normalized Units")
# manage settings
if self._pymcaSettings != dict():
......
......@@ -45,6 +45,46 @@ import logging
_logger = logging.getLogger(__file__)
def _normalized_exafs(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.get_missing_keys(('EXAFSKValues', 'EXAFSNormalized'))
if missing_keys:
_logger.error('missing keys:', missing_keys,
'unable to compute normalized EXAFS')
return None
if spectrum["KWeight"]:
if spectrum["KWeight"] == 1:
ylabel = "EXAFS Signal * k"
else:
ylabel = "EXAFS Signal * k^%d" % spectrum["KWeight"]
else:
ylabel = "EXAFS Signal"
idx = (spectrum["EXAFSKValues"] >= spectrum["KMin"]) & \
(spectrum["EXAFSKValues"] <= spectrum["KMax"])
return _CurveOperation(x=spectrum["EXAFSKValues"][idx],
y=spectrum["EXAFSNormalized"][idx],
legend="Normalized EXAFS",
ylabel=ylabel)
def _ft_window_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.ft.get_missing_keys(('K', 'WindowWeight'))
if missing_keys:
_logger.error('missing keys:', missing_keys,
'unable to compute normalized EXAFS')
return None
return _CurveOperation(x=spectrum.ft['K'],
y=spectrum.ft["WindowWeight"],
legend="FT Window",
yaxis="right",
color="red")
def _ft_intensity_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.ft.get_missing_keys(('FTRadius', 'FTIntensity'))
......@@ -73,9 +113,11 @@ class FTWindow(qt.QMainWindow):
qt.QMainWindow.__init__(self, parent)
# xas object viewer
self.xasObjViewer = XasObjectViewer(mapKeys=['Mu'])
self.xasObjViewer._spectrumView._plot.getXAxis().setLabel("R (Angstrom)")
self.xasObjViewer._spectrumView._plot.getYAxis().setLabel("Arbitrary Units")
self.xasObjViewer = XasObjectViewer(mapKeys=['Mu'], spectrumPlots=('FTWindow', 'FTIntensity'))
self.xasObjViewer._spectrumViews[0]._plot.getXAxis().setLabel("K")
self.xasObjViewer._spectrumViews[1]._plot.getXAxis().setLabel("R (Angstrom)")
self.xasObjViewer._spectrumViews[1]._plot.getYAxis().setLabel("Arbitrary Units")
self.setCentralWidget(self.xasObjViewer)
self._pymcaWindow = XASFourierTransformParameters(parent=self)
dockWidget = qt.QDockWidget(parent=self)
......@@ -86,20 +128,29 @@ class FTWindow(qt.QMainWindow):
dockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
dockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
# legend selector
self.legendDockWidget = LegendSelector.LegendsDockWidget(parent=self,
plot=self.xasObjViewer._spectrumView._plot)
self.legendDockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
self.legendDockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
self.addDockWidget(qt.Qt.RightDockWidgetArea, self.legendDockWidget)
# legend selectors
self.legendDockWidget1 = LegendSelector.LegendsDockWidget(parent=self,
plot=self.xasObjViewer._spectrumViews[0]._plot)
self.legendDockWidget1.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
self.legendDockWidget1.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
self.addDockWidget(qt.Qt.RightDockWidgetArea, self.legendDockWidget1)
self.legendDockWidget2 = LegendSelector.LegendsDockWidget(parent=self,
plot=self.xasObjViewer._spectrumViews[1]._plot)
self.legendDockWidget2.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
self.legendDockWidget2.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
self.addDockWidget(qt.Qt.RightDockWidgetArea, self.legendDockWidget2)
# volume key selection
self.addDockWidget(qt.Qt.RightDockWidgetArea,
self.xasObjViewer._mapView.keySelectionDocker)
# plot settings
for ope in (_normalized_exafs, _ft_window_plot):
self.xasObjViewer._spectrumViews[0].addCurveOperation(ope)
for ope in (_ft_intensity_plot, _ft_imaginary_plot):
self.xasObjViewer._spectrumView.addCurveOperation(ope)
self.xasObjViewer._spectrumViews[1].addCurveOperation(ope)
self.setWindowFlags(qt.Qt.Widget)
......@@ -113,8 +164,10 @@ class FTWindow(qt.QMainWindow):
return len(self.plot.getAllCurves())
def _updateLegendView(self):
self.legendDockWidget.setVisible(self.xasObjViewer.getViewType() is ViewType.spectrum)
self.xasObjViewer._mapView.keySelectionDocker.setVisible(self.xasObjViewer.getViewType() is ViewType.map)
index, viewType = self.xasObjViewer.getViewType()
self.legendDockWidget1.setVisible(viewType is ViewType.spectrum and index == 0)
self.legendDockWidget2.setVisible(viewType is ViewType.spectrum and index == 1)
self.xasObjViewer._mapView.keySelectionDocker.setVisible(viewType is ViewType.map)
class FTOW(_PyMcaProcessForOrangeMixIn, OWWidget):
......
......@@ -44,53 +44,9 @@ import logging
_logger = logging.getLogger(__file__)
def _normalized_exafs(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.get_missing_keys(('EXAFSKValues', 'EXAFSNormalized'))
if missing_keys:
_logger.error('missing keys:', missing_keys,
'unable to compute normalized EXAFS')
return None
if spectrum["KWeight"]:
if spectrum["KWeight"] == 1:
ylabel = "EXAFS Signal * k"
else:
ylabel = "EXAFS Signal * k^%d" % spectrum["KWeight"]
else:
ylabel = "EXAFS Signal"
idx = (spectrum["EXAFSKValues"] >= spectrum["KMin"]) & \
(spectrum["EXAFSKValues"] <= spectrum["KMax"])
return _CurveOperation(x=spectrum["EXAFSKValues"][idx],
y=spectrum["EXAFSNormalized"][idx],
legend="Normalized EXAFS",
ylabel=ylabel)
def _ft_window_plot(spectrum):
assert isinstance(spectrum, Spectrum)
missing_keys = spectrum.ft.get_missing_keys(('K', 'WindowWeight'))
if missing_keys:
_logger.error('missing keys:', missing_keys,
'unable to compute normalized EXAFS')
return None
return _CurveOperation(x=spectrum.ft['K'],
y=spectrum.ft["WindowWeight"],
legend="FT Window",
yaxis="right",
color="red")
class KWeightWindow(qt.QMainWindow):
def __init__(self, parent=None):
qt.QMainWindow.__init__(self, parent)
# xas object viewer
self.xasObjViewer = XasObjectViewer(mapKeys=['Mu'])
self.xasObjViewer._spectrumView._plot.getXAxis().setLabel("K")
self.setCentralWidget(self.xasObjViewer)
# k wright widget
self._k_widget = qt.QWidget(parent=self)
......@@ -105,36 +61,8 @@ class KWeightWindow(qt.QMainWindow):
dockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
dockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
# legend selector
self.legendDockWidget = LegendSelector.LegendsDockWidget(parent=self,
plot=self.xasObjViewer._spectrumView._plot)
self.legendDockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
self.legendDockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
self.addDockWidget(qt.Qt.RightDockWidgetArea, self.legendDockWidget)
# volume key selection
self.addDockWidget(qt.Qt.RightDockWidgetArea,
self.xasObjViewer._mapView.keySelectionDocker)
# plot settings
for ope in (_normalized_exafs, _ft_window_plot):
self.xasObjViewer._spectrumView.addCurveOperation(ope)
self.setWindowFlags(qt.Qt.Widget)
# connect signal / slot
self.xasObjViewer.viewTypeChanged.connect(self._updateLegendView)
# set up
self._updateLegendView()
def getNCurves(self):
return len(self.plot.getAllCurves())
def _updateLegendView(self, *args, **kwargs):
self.legendDockWidget.setVisible(self.xasObjViewer.getViewType() is ViewType.spectrum)
self.xasObjViewer._mapView.keySelectionDocker.setVisible(self.xasObjViewer.getViewType() is ViewType.map)
class KWeightOW(_PyMcaProcessForOrangeMixIn, OWWidget):
"""
......
......@@ -109,8 +109,8 @@ class NormalizationWindow(qt.QMainWindow):
# xas object viewer
mapKeys = ['Mu', 'NormalizedMu', 'NormalizedSignal', 'NormalizedBackground']
self.xasObjViewer = XasObjectViewer(mapKeys=mapKeys)
self.xasObjViewer._spectrumView._plot.getXAxis().setLabel("Energy (eV)")
self.xasObjViewer._spectrumView._plot.getYAxis().setLabel("Absorption (a.u.)")
self.xasObjViewer._spectrumViews[0]._plot.getXAxis().setLabel("Energy (eV)")
self.xasObjViewer._spectrumViews[0]._plot.getYAxis().setLabel("Absorption (a.u.)")
self.setCentralWidget(self.xasObjViewer)
self._pymcaWindow = XASNormalizationParameters(parent=self)
dockWidget = qt.QDockWidget(parent=self)
......@@ -123,7 +123,7 @@ class NormalizationWindow(qt.QMainWindow):
# legend selector
self.legendDockWidget = LegendSelector.LegendsDockWidget(parent=self,
plot=self.xasObjViewer._spectrumView._plot)
plot=self.xasObjViewer._spectrumViews[0]._plot)
self.legendDockWidget.setAllowedAreas(qt.Qt.RightDockWidgetArea | qt.Qt.LeftDockWidgetArea)
self.legendDockWidget.setFeatures(qt.QDockWidget.NoDockWidgetFeatures)
self.addDockWidget(qt.Qt.RightDockWidgetArea, self.legendDockWidget)
......@@ -135,7 +135,7 @@ class NormalizationWindow(qt.QMainWindow):
# plot settings
for ope in (_spectrum_plot, _normalized_spectrum_plot, _post_plot,
_pre_plot):
self.xasObjViewer._spectrumView.addCurveOperation(ope)
self.xasObjViewer._spectrumViews[0].addCurveOperation(ope)
self.setWindowFlags(qt.Qt.Widget)
......@@ -146,11 +146,12 @@ class NormalizationWindow(qt.QMainWindow):
self._updateLegendView()
def getNCurves(self):
return len(self.xasObjViewer._spectrumView._plot.getAllCurves())
return len(self.xasObjViewer._spectrumViews._plot.getAllCurves())
def _updateLegendView(self):
self.legendDockWidget.setVisible(self.xasObjViewer.getViewType() is ViewType.spectrum)
self.xasObjViewer._mapView.keySelectionDocker.setVisible(self.xasObjViewer.getViewType() is ViewType.map)
index, viewType = self.xasObjViewer.getViewType()
self.legendDockWidget.setVisible(viewType is ViewType.spectrum)
self.xasObjViewer._mapView.keySelectionDocker.setVisible(viewType is ViewType.map)
class NormalizationOW(_PyMcaProcessForOrangeMixIn, OWWidget):
......
......@@ -37,6 +37,7 @@ from silx.gui.plot import Plot1D
from silx.gui.plot.StackView import StackViewMainWindow
from silx.utils.enum import Enum
from silx.gui.widgets.FrameBrowser import HorizontalSliderWithBrowser
from xas.gui import icons
from silx.gui import icons as silx_icons
from silx.gui.colors import Colormap
......@@ -47,9 +48,16 @@ class ViewType(Enum):
class _SpectrumViewAction(qt.QAction):
def __init__(self, parent=None):
def __init__(self, parent=None, iView=0):
qt.QAction.__init__(self, 'spectrum view', parent=parent)
spectrum_icon = silx_icons.getQIcon("item-1dim")
assert iView in (0, 1) # for now we can only deal with two plot at max
# otherwise no more icon color to display
self._iView = iView
if iView == 0:
icon = "item-1dim"
elif iView == 1:
icon = "item-1dim-black"
spectrum_icon = icons.getQIcon(icon)
self.setIcon(spectrum_icon)
self.setCheckable(True)
......@@ -63,12 +71,17 @@ class _MapViewAction(qt.QAction):
class XasObjectViewer(qt.QMainWindow):
"""Viewer dedicated to view a XAS object"""
"""Viewer dedicated to view a XAS object
:param QObject parent: Qt parent
:param list mapKeys: list of str keys to propose for the map display
:param list spectrumsPlots: list of keys if several spectrum plot should be
proposed.
"""
viewTypeChanged = qt.Signal()
"""emitted when the view type change"""
def __init__(self, parent=None, mapKeys=None):
def __init__(self, parent=None, mapKeys=None, spectrumPlots=None):
qt.QMainWindow.__init__(self, parent)
self.setWindowFlags(qt.Qt.Widget)
......@@ -81,49 +94,67 @@ class XasObjectViewer(qt.QMainWindow):
self._mainWidget.layout().addWidget(self._mapView)
# spectrum view
self._spectrumView = SpectrumViewer(parent=self)
self._mainWidget.layout().addWidget(self._spectrumView)
self._spectrumViews = []
if spectrumPlots is not None:
spectrum_views_ = spectrumPlots
else:
spectrum_views_ = ('', )
for spectrumPlot in range(len(spectrum_views_)):
spectrumView = SpectrumViewer(parent=self)
self._mainWidget.layout().addWidget(spectrumView)
self._spectrumViews.append(spectrumView)
# add toolbar
toolbar = qt.QToolBar('')
toolbar.setIconSize(qt.QSize(32, 32))
self._spectrumViewActions = []
self.view_actions = qt.QActionGroup(self)
self._spectrumViewAction = _SpectrumViewAction()
self.view_actions.addAction(self._spectrumViewAction)
for iSpectrumView, tooltip in enumerate(spectrum_views_):
spectrumViewAction = _SpectrumViewAction(parent=None,
iView=iSpectrumView)
self.view_actions.addAction(spectrumViewAction)
self._spectrumViewActions.append(spectrumViewAction)
spectrumViewAction.setToolTip(tooltip)
toolbar.addAction(spectrumViewAction)
self._mapViewAction = _MapViewAction()
self.view_actions.addAction(self._mapViewAction)
toolbar.addAction(self._spectrumViewAction)
toolbar.addAction(self._mapViewAction)
self.view_actions.addAction(self._mapViewAction)
self.addToolBar(qt.Qt.LeftToolBarArea, toolbar)
toolbar.setMovable(False)
# connect signal / Slot
self._mapViewAction.triggered.connect(self._updateView)
self._spectrumViewAction.triggered.connect(self._updateView)
for spectrumAction in self._spectrumViewActions:
spectrumAction.triggered.connect(self._updateView)
# initialize
self._spectrumViewAction.setChecked(True)
self._spectrumViewActions[0].setChecked(True)
self._updateView()
def _updateView(self, *arg, **kwargs):
self._mapView.setVisible(self.getViewType() is ViewType.map)
self._spectrumView.setVisible(self.getViewType() is ViewType.spectrum)
index, view_type = self.getViewType()
self._mapView.setVisible(view_type is ViewType.map)
for iView, spectrumView in enumerate(self._spectrumViews):
spectrumView.setVisible(view_type is ViewType.spectrum and iView == index)
self.viewTypeChanged.emit()
def getViewType(self):
if self._mapViewAction.isChecked():
return ViewType.map
elif self._spectrumViewAction.isChecked():
return ViewType.spectrum
return None, ViewType.map
else:
for spectrumViewAction in self._spectrumViewActions:
if spectrumViewAction.isChecked():
return spectrumViewAction._iView, ViewType.spectrum
return None, None
def setXASObj(self, xas_obj):
self._mapView.clear()
self._spectrumView.clear()
self._mapView.setXasObject(xas_obj)
self._spectrumView.setXasObject(xas_obj)
for spectrumView in self._spectrumViews:
spectrumView.clear()
spectrumView.setXasObject(xas_obj)
class MapViewer(qt.QWidget):
......@@ -274,7 +305,7 @@ class SpectrumViewer(qt.QMainWindow):
spectrum = self.xas_obj.getSpectrum(dim1_index, dim2_index)
for operation in self._curveOperations:
res = operation(spectrum)
if res is not None:
if res is not None and res.x is not None:
assert isinstance(res, _CurveOperation)
self._plot.addCurve(x=res.x,
y=res.y,
......
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2016 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
"""Set of icons for buttons.
Use :func:`getQIcon` to create Qt QIcon from the name identifying an icon.
"""
__authors__ = ["T. Vincent"]
__license__ = "MIT"
__date__ = "07/01/2019"
import os
import logging
import weakref
from silx.gui import qt
import xas.resources
from silx.utils import weakref as silxweakref
from silx.utils.deprecation import deprecated
_logger = logging.getLogger(__name__)
"""Module logger"""
_cached_icons = None
"""Cache loaded icons in a weak structure"""
def getIconCache():
"""Get access to all cached icons
:rtype: dict
"""
global _cached_icons
if _cached_icons is None:
_cached_icons = weakref.WeakValueDictionary()
# Clean up the cache before leaving the application
# See https://github.com/silx-kit/silx/issues/1771
qt.QApplication.instance().aboutToQuit.connect(cleanIconCache)
return _cached_icons
def cleanIconCache():
"""Clean up the icon cache"""
_logger.debug("Clean up icon cache")
_cached_icons.clear()
_supported_formats = None
"""Order of file format extension to check"""
class AbstractAnimatedIcon(qt.QObject):
"""Store an animated icon.
It provides an event containing the new icon everytime it is updated."""
def __init__(self, parent=None):
"""Constructor
:param qt.QObject parent: Parent of the QObject
:raises: ValueError when name is not known
"""
qt.QObject.__init__(self, parent)
self.__targets = silxweakref.WeakList()
self.__currentIcon = None
iconChanged = qt.Signal(qt.QIcon)
"""Signal sent with a QIcon everytime the animation changed."""
def register(self, obj):
"""Register an object to the AnimatedIcon.
If no object are registred, the animation is paused.
Object are stored in a weaked list.
:param object obj: An object
"""
if obj not in self.__targets:
self.__targets.append(obj)
self._updateState()
def unregister(self, obj):
"""Remove the object from the registration.
If no object are registred the animation is paused.
:param object obj: A registered object
"""
if obj in self.__targets:
self.__targets.remove(obj)
self._updateState()
def hasRegistredObjects(self):
"""Returns true if any object is registred.
:rtype: bool
"""
return len(self.__targets)
def isRegistered(self, obj):