update references to record.py
[sface.git] / sface-run
1 #!/usr/bin/env python
2
3 import os
4 import sys
5 from optparse import OptionParser
6
7 sys.path.insert(0, ".")
8 exe = os.path.abspath(sys.argv[0])
9
10 def using_env(e):
11     print "Using %s = %s" % (e, os.environ[e])
12
13 def print_env(config):
14     if not config.verbose:
15         return
16
17     if sys.platform == "darwin":
18         using_env("DYLD_FRAMEWORK_PATH")
19         using_env("DYLD_LIBRARY_PATH")
20
21     using_env("PATH")
22     print "Using sys.path =", sys.path
23
24 if sys.platform == "darwin":
25     # for testing on mac os x 10.5 - baris
26     sys.path.append("/opt/local/lib/python2.5/site-packages/")
27
28     DIR = os.path.dirname(exe)
29     CONTENTS = os.path.dirname(DIR)
30     RESOURCES = os.path.join(CONTENTS, "Resources")
31     FRAMEWORKS = os.path.join(CONTENTS, "Frameworks")
32      
33     DYLD_FRAMEWORK_PATH = FRAMEWORKS
34     DYLD_LIBRARY_PATH = RESOURCES
35     PATH = os.getenv("PATH")
36     SFI_PATH = os.path.join(RESOURCES, "sfa/client")
37     PATH=":".join([RESOURCES, SFI_PATH, PATH])
38
39     os.environ["PATH"] = PATH
40     os.environ["DYLD_LIBRARY_PATH"] = DYLD_LIBRARY_PATH
41     os.environ["DYLD_FRAMEWORK_PATH"] = DYLD_FRAMEWORK_PATH
42     if os.path.exists(RESOURCES):  sys.path.insert(0, RESOURCES)
43     if os.path.exists(FRAMEWORKS): sys.path.insert(0, FRAMEWORKS)
44
45 elif sys.platform == "linux2":
46     sys.path.extend(["/usr/share", "/usr/share/sface"])
47
48
49 from PyQt4.QtGui import *
50 from sface.mainwindow import MainWindow
51 from sface.config import config
52
53 def main(args):
54     app = QApplication(args)
55     app.setStyleSheet('''
56 /* transparency
57 QDialog, MainWindow {
58   background-color:rgba(255,255,255,120);
59 }
60 */
61
62 QTreeView, QLineEdit { 
63   border: 2px solid gray;
64   border-radius: 4px;
65   padding: 1px;
66   margin: 2px;
67 }
68
69 QPushButton {
70   background-color: white;
71   border: 2px solid gray;
72   border-radius: 4px;
73   padding: 6px;
74 }
75
76 QPushButton:pressed {
77   background-color: #5599FF;
78 }
79
80 QLabel {
81   font-size: 14px;
82 }
83
84 ''')
85
86
87     win = MainWindow()
88     win.redirectOutputToLog()
89     win.setWindowTitle("Sface: SFA Interface")
90     win.show()
91     win.raise_()
92     win.activateWindow()
93     app.setActiveWindow(win)
94
95     sys.exit(app.exec_())
96
97
98 if __name__ == "__main__":
99     parser=OptionParser()
100     config.add_options_to_OptionParser(parser)
101     (options,args)=parser.parse_args()
102     config.update_from_OptionParser(options)
103     config.display("After command-line")
104     print_env(config)
105     main(sys.argv)