1 # Most of the common code needed by ROX applications is in ROX-Lib2.
2 # Except this code, which is needed to find ROX-Lib2 in the first place!
4 # Just make sure you import findrox before importing anything inside
8 from os
.path
import exists
12 path
= os
.environ
['LIBDIRPATH']
13 paths
= string
.split(path
, ':')
15 paths
= [ os
.environ
['HOME'] + '/lib', '/usr/local/lib', '/usr/lib' ]
17 paths
= map(lambda p
: os
.path
.join(p
, 'ROX-Lib2'), paths
)
20 sys
.path
.append(os
.path
.join(p
, 'python'))
23 err
= "This program needs ROX-Lib2 to run.\n" + \
24 "I tried all of these places:\n\n" + \
25 string
.join(paths
, '\n') + '\n\n' + \
26 "ROX-Lib2 is available from:\nhttp://rox.sourceforge.net"
28 sys
.stderr
.write('*** ' + err
+ '\n')
36 message
= gtk
.GtkLabel(err
+
37 '\n\nAlso, pygtk2 needs to be present')
38 win
.set_title('Missing ROX-Lib2')
39 win
.set_position(gtk
.WIN_POS_CENTER
)
40 message
.set_padding(20, 20)
41 win
.vbox
.pack_start(message
)
43 ok
= gtk
.GtkButton("OK")
44 ok
.set_flags(gtk
.CAN_DEFAULT
)
45 win
.action_area
.pack_start(ok
)
46 ok
.connect('clicked', gtk
.mainquit
)
49 win
.connect('destroy', gtk
.mainquit
)
53 box
= g
.MessageDialog(None, g
.MESSAGE_ERROR
, 0,
55 box
.set_title('Missing ROX-Lib2')
56 box
.set_position(g
.WIN_POS_CENTER
)
57 box
.set_default_response(g
.RESPONSE_OK
)