summaryrefslogtreecommitdiff
path: root/alot/widgets
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-08-18 17:22:23 -0700
committerDylan Baker <dylan@pnwbakers.com>2017-08-19 12:52:26 -0700
commit22557647bdbc003b5ca70e39720cca78c77d9b39 (patch)
treeee22acd1932f724e3a6b4ed73732f8780d002e67 /alot/widgets
parenta8893b2840de4fbe280dd69f5b75051dadb04897 (diff)
widgets/globals: Implement __hash__ for TagWidget
Which is required in python3 when implementing the __eq__ method. The implementation caches the hash method, since it's being called each time the focus is changed in the search view. This doesn't really seem correct to me, but I'm not sure it's wrong.
Diffstat (limited to 'alot/widgets')
-rw-r--r--alot/widgets/globals.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/alot/widgets/globals.py b/alot/widgets/globals.py
index 6756149d..e4b9fada 100644
--- a/alot/widgets/globals.py
+++ b/alot/widgets/globals.py
@@ -292,6 +292,7 @@ class TagWidget(urwid.AttrMap):
self.translated = representation['translated']
self.hidden = self.translated == ''
self.txt = urwid.Text(self.translated, wrap='clip')
+ self.__hash = hash('{}_{}'.format(self.translated, self.txt))
normal_att = representation['normal']
focus_att = representation['focussed']
self.attmaps = {'normal': normal_att, 'focus': focus_att}
@@ -343,3 +344,6 @@ class TagWidget(urwid.AttrMap):
if not isinstance(other, TagWidget):
return NotImplemented
return self.translated.lower() != other.translated.lower()
+
+ def __hash__(self):
+ return self.__hash