Browse files

More documentation (basegui.py)

  • Loading branch information...
1 parent d4f1bad commit a9cf56aeeb39738109a4879a68db8b023ce4c1ac @themoken committed Jun 11, 2009
Showing with 14 additions and 0 deletions.
  1. +14 −0 canto/basegui.py
View
14 canto/basegui.py
@@ -7,9 +7,20 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
+# BaseGui enforces that all gui objects have the same basic interface. For
+# BaseGui ever single function is at least partially overridden, but the Reader
+# class can take most of it at default value.
+
from const import NOKEY
class BaseGui:
+ def __init__(self):
+ self.keys = {}
+
+ def draw_elements():
+ pass
+
+ # Translate a key into a set of actions based on self.keys
def key(self, k):
if k in self.keys:
if type(self.keys[k]) == list:
@@ -18,6 +29,9 @@ def key(self, k):
else:
return []
+ # Perform the action. If it's a string, attempt to look it up as an
+ # attribute of the self object. If it's a callable, go ahead and call it.
+
def action(self, a):
if hasattr(a, "__call__"):
r = a(self)

0 comments on commit a9cf56a

Please sign in to comment.