summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Holland <william.holland@codethink.co.uk>2015-06-01 14:40:07 +0100
committerWilliam Holland <william.holland@codethink.co.uk>2015-06-01 14:40:07 +0100
commitf8311306f6499a992c21a231361afc62132cbef3 (patch)
tree3c76695f69123bb94642c01c8ba01bb59891b572
parent0f5c2a246768adabf111fdbd287deff3b6fb630c (diff)
downloadkeyboard-python-f8311306f6499a992c21a231361afc62132cbef3.tar.bz2
Fix bool not working for KeyCombination
-rw-r--r--keyboardpython/key.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/keyboardpython/key.py b/keyboardpython/key.py
index 278668d..b820631 100644
--- a/keyboardpython/key.py
+++ b/keyboardpython/key.py
@@ -45,7 +45,7 @@ class KeyCombination:
return hash(str(self))
def __nonzero__(self):
- return bool(self.keys())
+ return bool(self.string)
def contains_key(self,key):
''' is key in this combination? '''
@@ -58,6 +58,7 @@ class KeyCombination:
if self.contains_key(_key): return
self.keys.append(_key)
self.keys = list(set(self.keys))
+ self.string = self.__string()
def remove_key(self,key):
''' remove key from this combination '''
@@ -65,12 +66,14 @@ class KeyCombination:
if key in self.keys:
key_index = self.keys.index(key)
self.keys.pop(key_index)
+ self.string = self.__string()
def add_keyCombination(self,key_comb):
''' add each key from key_comb to this combination '''
assert isinstance(key_comb,KeyCombination)
for _key in key_comb.keys: self.keys.append(_key)
self.keys = list(set(self.keys))
+ self.string = self.__string()
def diff(self,key_comb):
''' return keys in key_comb that aren't in this combination '''