1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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)
|