Skip to content

Commit

Permalink
Better code.
Browse files Browse the repository at this point in the history
  • Loading branch information
dddomodossola committed Feb 15, 2021
1 parent fdddf85 commit 6dbe6c8
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions remi/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,8 @@ def add_annotation(prop):
class _EventDictionary(dict, EventSource):
"""This dictionary allows to be notified if its content is changed.
"""

changed = False
def __init__(self, *args, **kwargs):
self.__version__ = 0
self.__lastversion__ = 0
super(_EventDictionary, self).__init__(*args, **kwargs)
EventSource.__init__(self, *args, **kwargs)

Expand Down Expand Up @@ -269,16 +267,16 @@ def update(self, d):
return ret

def ischanged(self):
return self.__version__ != self.__lastversion__
return self.changed

def align_version(self):
self.__lastversion__ = self.__version__
self.changed = False

@decorate_event
def onchange(self):
"""Called on content change.
"""
self.__version__ += 1
self.changed = True
return ()


Expand Down Expand Up @@ -401,7 +399,7 @@ def _need_update(self, emitter=None, child_ignore_update=False):
self.get_parent()._need_update(child_ignore_update = (self.ignore_update or child_ignore_update))

def _ischanged(self):
return self.children.ischanged() or self.attributes.ischanged() or self.style.ischanged()
return self.children.changed or self.attributes.changed or self.style.changed

def _set_updated(self):
self.children.align_version()
Expand Down

0 comments on commit 6dbe6c8

Please sign in to comment.