Initial Python 3 compatible code

This commit is contained in:
2019-06-06 11:52:23 -05:00
parent d441536f01
commit ef689d04fc
146 changed files with 589 additions and 246 deletions

View File

@@ -18,17 +18,17 @@ class KeyboardHandler(object):
def register_key (self, key, function):
if key in self.active_keys:
raise KeyboardHandlerError, "Key %s is already registered to a function" % key
raise KeyboardHandlerError("Key %s is already registered to a function" % key)
if not callable(function):
raise TypeError, "Must provide a callable to be invoked upon keypress"
raise TypeError("Must provide a callable to be invoked upon keypress")
self.active_keys[key] = function
def unregister_key (self, key, function):
try:
if self.active_keys[key] != function:
raise KeyboardHandlerError, "key %s is not registered to that function" % key
raise KeyboardHandlerError("key %s is not registered to that function" % key)
except KeyError:
raise KeyboardHandlerError, "Key %s not currently registered"
raise KeyboardHandlerError("Key %s not currently registered" % key)
del(self.active_keys[key])
def unregister_all_keys(self):