Minor doc updates for the new release.
[rox-archive.git] / findrox.py
blob981e208f7c3482e4888d6d0d588e630449b73977
1 # Most of the common code needed by ROX applications is in ROX-Lib.
2 # Except this code, which is needed to find ROX-Lib in the first place!
4 # Just make sure you import findrox before importing anything inside
5 # ROX-Lib...
7 import os, sys
8 from os.path import exists
9 import string
11 try:
12 path = os.environ['LIBDIRPATH']
13 paths = string.split(path, ':')
14 except KeyError:
15 paths = [ os.environ['HOME'] + '/lib', '/usr/local/lib', '/usr/lib' ]
17 paths = map(lambda p: p +'/ROX-Lib', paths)
18 found = 0
19 for p in paths:
20 if exists(p):
21 found = 1
22 sys.path.append(p + '/python')
23 break
24 if not found:
25 err = "This program needs ROX-Lib to run.\nI tried all of these places:\n\n" + \
26 string.join(paths, '\n') + '\n\n' + "ROX-Lib is available from:\n" + \
27 "http://rox.sourceforge.net"
28 sys.stderr.write('*** ' + err + '\n')
29 from gtk import *
30 win = GtkDialog()
31 win.set_title('Missing ROX-Lib')
32 win.set_position(WIN_POS_CENTER)
33 message = GtkLabel(err)
34 message.set_padding(20, 20)
35 win.vbox.pack_start(message)
37 ok = GtkButton("OK")
38 ok.set_flags(CAN_DEFAULT)
39 win.action_area.pack_start(ok)
40 ok.connect('clicked', mainquit)
41 ok.grab_default()
43 win.connect('destroy', mainquit)
44 win.show_all()
45 mainloop()
46 sys.exit(1)