From efd45f97d79bb2642a9cb05c963f04894e5f0d3c Mon Sep 17 00:00:00 2001 From: lassoan Date: Sun, 29 Dec 2019 04:21:56 +0000 Subject: [PATCH] ENH: Allow specifying observation priority to VTKObservationMixin git-svn-id: http://svn.slicer.org/Slicer4/trunk@28705 3bd1e089-480b-0410-8dfb-8563597acbee --- Base/Python/slicer/util.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Base/Python/slicer/util.py b/Base/Python/slicer/util.py index 656da16c1bc..7c72c83ed45 100644 --- a/Base/Python/slicer/util.py +++ b/Base/Python/slicer/util.py @@ -1423,32 +1423,32 @@ def __init__(self): self.Observations = [] def removeObservers(self, method=None): - for o, e, m, g, t in list(self.Observations): + for o, e, m, g, t, p in list(self.Observations): if method == m or method is None: o.RemoveObserver(t) - self.Observations.remove([o, e, m, g, t]) + self.Observations.remove([o, e, m, g, t, p]) - def addObserver(self, object, event, method, group = 'none'): + def addObserver(self, object, event, method, group = 'none', priority = 0.0): if self.hasObserver(object, event, method): print('already has observer') return - tag = object.AddObserver(event, method) - self.Observations.append([object, event, method, group, tag]) + tag = object.AddObserver(event, method, priority) + self.Observations.append([object, event, method, group, tag, priority]) def removeObserver(self, object, event, method): - for o, e, m, g, t in self.Observations: + for o, e, m, g, t, p in self.Observations: if o == object and e == event and m == method: o.RemoveObserver(t) - self.Observations.remove([o, e, m, g, t]) + self.Observations.remove([o, e, m, g, t, p]) def hasObserver(self, object, event, method): - for o, e, m, g, t in self.Observations: + for o, e, m, g, t, p in self.Observations: if o == object and e == event and m == method: return True return False def observer(self, event, method): - for o, e, m, g, t in self.Observations: + for o, e, m, g, t, p in self.Observations: if e == event and m == method: return o return None