00001 #!/usr/local/bin/python 00002 # 00003 # Copyright 2002 00004 # by 00005 # The Board of Trustees of the 00006 # Leland Stanford Junior University. 00007 # All rights reserved. 00008 # 00009 00010 __facility__ = "Online" 00011 __abstract__ = "GLAST LAT GUI for Online Run Control" 00012 __author__ = """A. Kavelaars <AliciaK@SLAC.Stanford.edu> 00013 SLAC - GLAST LAT I&T/Online""" 00014 __date__ = "11/13/2002" 00015 __version__ = "$Revision: 2.2 $" 00016 __credits__ = "SLAC" 00017 00018 import LATTE.copyright_SLAC 00019 00020 00021 import sys, os 00022 from qt import * 00023 from RunControlGUI import RunControlGUI 00024 from ConfigParser import ConfigParser 00025 from rcPreferencesGUIImpl import rcPreferencesGUIImpl 00026 00027 00028 class RunControlGUIImpl(RunControlGUI): 00029 00030 def __init__(self, common, parent = None, name = None, fl = 0): 00031 RunControlGUI.__init__(self, parent, name, fl) 00032 00033 self.connect(self.SetupButton,SIGNAL("clicked()"),self.SetupClicked) 00034 self.connect(self.TeardownButton,SIGNAL("clicked()"),self.TeardownClicked) 00035 self.connect(self.StartRunButton,SIGNAL("clicked()"),self.StartRunClicked) 00036 self.connect(self.StopRunButton,SIGNAL("clicked()"),self.StopRunClicked) 00037 self.connect(self.ResumeButton,SIGNAL("clicked()"),self.ResumeClicked) 00038 self.connect(self.PauseButton,SIGNAL("clicked()"),self.PauseClicked) 00039 self.connect(self.StopButton,SIGNAL("clicked()"),self.StopClicked) 00040 00041 self.connect(self.AppOpenButton,SIGNAL("clicked()"),self.load) 00042 self.connect(self.ExitButton,SIGNAL("clicked()"),self.ExitButtonClicked) 00043 00044 self.connect(self.fileSelect_SchemaAction,SIGNAL("activated()"),self.loadSchema) 00045 self.connect(self.fileConnectAction,SIGNAL("activated()"),self.connectClicked) 00046 00047 defaultDir = "" 00048 self.__prefs = common.prefMan().preferences() 00049 self.__common = common 00050 00051 self._currentSchema = self.__prefs['reposdir'] 00052 00053 def common(self): 00054 return self.__common 00055 00056 def preferences(self): 00057 return self.__prefs 00058 00059 def getCommentWidget(self): 00060 return None 00061 00062 def PreferencesActivated(self): 00063 prefGUI = self.__common.prefGUI() 00064 prefGUI.loadConfig() 00065 status = prefGUI.exec_loop() 00066 if status == prefGUI.Accepted: 00067 pass 00068 elif status == prefGUI.Rejected: 00069 # Use "factory" defaults; cfg file not updated 00070 pass 00071 00072 def SetupClicked(self): 00073 print "Button pressed: %s" % 'SETUP' 00074 00075 def TeardownClicked(self): 00076 print "Button pressed: %s" % 'TEARDOWN' 00077 00078 def StartRunClicked(self): 00079 print "Button pressed: %s" % 'START_RUN' 00080 00081 def StopRunClicked(self): 00082 print "Button pressed: %s" % 'STOP_RUN' 00083 00084 def PauseClicked(self): 00085 print "Button pressed: %s" % 'PAUSE' 00086 00087 def ResumeClicked(self): 00088 print "Button pressed: %s" % 'RESUME' 00089 00090 def StopClicked(self): 00091 print "Button pressed: %s" % 'STOP' 00092 00093 def load(self): 00094 applName = QFileDialog.getOpenFileName(self.__prefs["appdir"], "(*.py)", 00095 self, "Application file dialog", 00096 "Choose an application") 00097 if applName.isEmpty(): 00098 return None 00099 00100 self.__prefs["appdir"] = applName 00101 00102 self.OpenAppl.setText(applName) 00103 00104 return applName 00105 00106 def loadSchema(self): 00107 rcSchemaSel = rcFileSelector(self._currentSchema, "(*.xml)", self, "Select a schema") 00108 schemaName = rcSchemaSel.getValue() 00109 # Allow the C++ object to be deleted 00110 rcSchemaSel.deleteLater() 00111 if schemaName is None: return 00112 self._currentSchema = schemaName 00113 self.__common.readSchema(schemaName) 00114 00115 def ExitButtonClicked(self): 00116 self.close() 00117 00118 def fileNew(self): 00119 print "RunControlTempImpl.fileNew(): Not implemented yet" 00120 00121 def fileOpen(self): 00122 print "RunControlTempImpl.fileOpen(): Not implemented yet" 00123 00124 def fileSave(self): 00125 print "RunControlTempImpl.fileSave(): Not implemented yet" 00126 00127 def fileSaveAs(self): 00128 print "RunControlTempImpl.fileSaveAs(): Not implemented yet" 00129 00130 def filePrint(self): 00131 print "RunControlTempImpl.filePrint(): Not implemented yet" 00132 00133 def fileExit(self): 00134 print "RunControlTempImpl.fileExit(): Not implemented yet" 00135 00136 def editUndo(self): 00137 print "RunControlTempImpl.editUndo(): Not implemented yet" 00138 00139 def editRedo(self): 00140 print "RunControlTempImpl.editRedo(): Not implemented yet" 00141 00142 def editCut(self): 00143 print "RunControlTempImpl.editCut(): Not implemented yet" 00144 00145 def editCopy(self): 00146 print "RunControlTempImpl.editCopy(): Not implemented yet" 00147 00148 def editPaste(self): 00149 print "RunControlTempImpl.editPaste(): Not implemented yet" 00150 00151 def editFind(self): 00152 print "RunControlTempImpl.editFind(): Not implemented yet" 00153 00154 def helpIndex(self): 00155 print "RunControlTempImpl.helpIndex(): Not implemented yet" 00156 00157 def helpContents(self): 00158 print "RunControlTempImpl.helpContents(): Not implemented yet" 00159 00160 def helpAbout(self): 00161 print "RunControlTempImpl.helpAbout(): Not implemented yet" 00162 00163 00164 class rcFileSelector(QFileDialog): 00165 def __init__(self, startwith, filter, parent, name): 00166 QFileDialog.__init__(self, parent, name, 0) 00167 self.setMode(QFileDialog.ExistingFile) 00168 self.setFilter(filter) 00169 self.setDir(os.path.dirname(startwith)) 00170 self.setCaption(name) 00171 self.setViewMode( QFileDialog.Detail) 00172 self.setSelection(startwith) 00173 00174 def getValue(self): 00175 if self.exec_loop() == QDialog.Accepted: 00176 return str(self.selectedFile()) 00177 else: 00178 return None 00179 00180 if __name__ == "__main__": 00181 a = QApplication(sys.argv) 00182 QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()")) 00183 w = RunControlGUI() 00184 a.setMainWidget(w) 00185 w.show() 00186 a.exec_loop()