mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-08-29 19:21:34 +00:00
Initial Python 3 compatible code
This commit is contained in:
@@ -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):
|
||||
|
Reference in New Issue
Block a user