00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 __facility__ = "Online"
00016 __abstract__ = "Main GUI startup code - modified from startupMainGUI for LICOS"
00017 __author__ = "S. Tuvi <stuvi@SLAC.Stanford.edu> SLAC - GLAST I&T/Online"
00018 __date__ = "2005/07/15 23:45:02"
00019 __updated__ = "$Date: 2006/03/08 00:32:20 $"
00020 __version__ = "$Revision: 1.5 $"
00021 __release__ = "$Name: HEAD $"
00022 __credits__ = "SLAC"
00023
00024
00025 import LICOS.copyright_SLAC
00026
00027 import os, threading
00028 from qt import *
00029 import logging as log
00030
00031 from LICOS.scriptEngine.ScriptEngineCommon import ScriptEngineCommon
00032 from LICOS.scriptEngine.ScriptEngineMain import ScriptEngineMain
00033
00034 def startupScriptEngine():
00035 """!\brief Start up the script engine.
00036
00037 """
00038
00039
00040 global DBN
00041
00042 rcCommon = ScriptEngineCommon()
00043
00044 app = rcCommon.getQtApp()
00045 QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
00046
00047 rcCommon.initialize(startup=True)
00048
00049 rcCommon.EBFdistribution()
00050
00051 initStyle(rcCommon.preferences())
00052 runCtl = ScriptEngineMain(rcCommon)
00053 runCtl.connectClicked()
00054 app.setMainWidget(runCtl)
00055 runCtl.show()
00056
00057 if rcCommon.options().securedir is not None:
00058 login = runCtl.login()
00059 if login == None or login == -2:
00060 app.quit()
00061 return
00062 else:
00063 runCtl.fileLogoutAction.setEnabled(0)
00064
00065 if rcCommon.options().vscConfig is not None:
00066 if not rcCommon.configureHardware():
00067 app.quit()
00068 return
00069
00070 DBN = rcCommon.getDBN()
00071 DBN['_prefs'] = rcCommon.preferences()
00072
00073 threading.currentThread().setName("LICOS_GUI")
00074 app.exec_loop()
00075
00076 def initStyle(prefs):
00077 """!\brief Initialize the visual style based on preferences.
00078
00079 \param prefs Preferences
00080
00081 """
00082 if prefs.has_key('style'):
00083 style = prefs['style']
00084 if style in QStyleFactory.keys():
00085 qApp.setStyle(QStyleFactory.create(style))
00086 font = QApplication.font()
00087 if prefs.has_key('fontfamily'):
00088 font.setFamily(prefs['fontfamily'])
00089 if prefs.has_key('fontsize'):
00090 font.setPointSize(int(prefs['fontsize']))
00091 if prefs.has_key('fontweight'):
00092 font.setWeight(int(prefs['fontweight']))
00093 if prefs.has_key('fontitalic'):
00094 font.setItalic(int(prefs['fontitalic']))
00095 qApp.setFont(font)
00096
00097 if __name__ == '__main__':
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 startupScriptEngine()