summaryrefslogtreecommitdiff
path: root/gem/aes.py
diff options
context:
space:
mode:
authorJeff Armstrong <jeffrey.armstrong@approximatrix.com>2011-07-19 22:01:34 -0400
committerJeff Armstrong <jeffrey.armstrong@approximatrix.com>2011-07-19 22:01:34 -0400
commitaaeadf736a441ddc0d18b29a341124d6f764c376 (patch)
tree0e490d4fa306edc45faae94844a248b248dcbde2 /gem/aes.py
parent825524f90e714e29469895467d34a0f4ce02ca76 (diff)
downloadgempy-aaeadf736a441ddc0d18b29a341124d6f764c376.tar.gz
gempy-aaeadf736a441ddc0d18b29a341124d6f764c376.zip
Started implementing Pythonic interfaces to GEM routines.
Diffstat (limited to 'gem/aes.py')
-rw-r--r--gem/aes.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/gem/aes.py b/gem/aes.py
new file mode 100644
index 0000000..ac29463
--- /dev/null
+++ b/gem/aes.py
@@ -0,0 +1,64 @@
+import _gem
+
+from error import GEMError
+
+def alert(message,type=None,buttons=('Ok',),default=None):
+ """Displays a generic GEM alert box with the specified
+ message. The type of box may also be specified as one
+ of ('none', 'exclamation', 'question', 'stop', 'info',
+ 'disk', 'bomb'). The buttons parameter can contain a
+ tuple or list of button texts (up to 3, as limited by
+ GEM."""
+
+ alert_types = ['none', 'exclamation', 'question',
+ 'stop', 'info', 'disk', 'bomb']
+ try:
+ internal_type = alert_type.index(type.lower())
+ except ValueError:
+ raise GEMError('Unknown alert box type')
+ except AttributeError:
+ if type is None:
+ internal_type = 0
+ else:
+ internal_type = type
+
+ if default is None:
+ default = 0
+ elif type(default) is str:
+ try:
+ default = buttons.index(default)
+ except ValueError:
+ raise GEMError('Could not locate default button')
+
+ bstring = ''
+ if len(buttons) > 3:
+ buttons = buttons[0:3]
+ for button in buttons:
+ if len(button) > 10:
+ button = button[0:10]
+ bstring = bstring + button + '|'
+ bstring = bstring[:-1]
+
+ astring = "[{0}][{1}][{2}]".format(repr(internal_type),
+ message, bstring)
+
+ return _gem.form_alert(default, astring)
+
+class Window:
+ def __init__(self, type):
+
+ self.id = _gem.wind_create(type,(0,0,10,10))
+
+
+class Application:
+
+ def __init__(self):
+ self.id = _gem.appl_init()
+ if self.id == -1:
+ raise GEMError("The application failed to initialize")
+
+ self.windows = []
+
+ def destroy(self):
+ _gem.appl_exit(self.id)
+ \ No newline at end of file