diff options
| author | Jeff Armstrong <jeffrey.armstrong@approximatrix.com> | 2011-07-19 22:01:34 -0400 |
|---|---|---|
| committer | Jeff Armstrong <jeffrey.armstrong@approximatrix.com> | 2011-07-19 22:01:34 -0400 |
| commit | aaeadf736a441ddc0d18b29a341124d6f764c376 (patch) | |
| tree | 0e490d4fa306edc45faae94844a248b248dcbde2 /gem | |
| parent | 825524f90e714e29469895467d34a0f4ce02ca76 (diff) | |
| download | gempy-aaeadf736a441ddc0d18b29a341124d6f764c376.tar.gz gempy-aaeadf736a441ddc0d18b29a341124d6f764c376.zip | |
Started implementing Pythonic interfaces to GEM routines.
Diffstat (limited to 'gem')
| -rw-r--r-- | gem/__init__.py | 3 | ||||
| -rw-r--r-- | gem/aes.py | 64 | ||||
| -rw-r--r-- | gem/error.py | 8 |
3 files changed, 75 insertions, 0 deletions
diff --git a/gem/__init__.py b/gem/__init__.py new file mode 100644 index 0000000..2d45559 --- /dev/null +++ b/gem/__init__.py @@ -0,0 +1,3 @@ +
+from aes import *
+from error import *
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 diff --git a/gem/error.py b/gem/error.py new file mode 100644 index 0000000..2aee47d --- /dev/null +++ b/gem/error.py @@ -0,0 +1,8 @@ +
+
+class GEMError(Exception):
+ """An exception related to GEM"""
+ def __init__(self, value):
+ self.value = value
+ def __str__(self):
+ return repr(self.value)
\ No newline at end of file |
