00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 __facility__ = "Online"
00011 __abstract__ = "Sample application based on seAppBase"
00012 __author__ = "S. Tuvi <stuvi@SLAC.Stanford.edu> SLAC - GLAST LAT I&T/Online"
00013 __date__ = "2005/07/23 00:08:27"
00014 __updated__ = "$Date: 2005/09/29 00:25:06 $"
00015 __version__ = "$Revision: 1.5 $"
00016 __release__ = "$Name: HEAD $"
00017 __credits__ = "SLAC"
00018
00019 import LICOS.copyright_SLAC
00020
00021 import time
00022 import logging as log
00023
00024 from LICOS.lib.scriptEngine.seAppBase import seAppBase
00025 from LICOS.lib.scriptEngine.ArgumentImpl import ArgumentImpl
00026
00027 class testAppInput(seAppBase):
00028 def __init__(self, common):
00029 seAppBase.__init__(self, common)
00030
00031 def setup(self):
00032 log.debug("%s setup" % self.getName())
00033
00034 def teardown(self):
00035 log.debug("%s teardown" % self.getName())
00036 if self.rc is not None and self.__arg is not None:
00037
00038 self.__arg.deleteLater()
00039
00040 def startRun(self):
00041 log.debug("%s startRun" % self.getName())
00042
00043 caption = "Enter count:"
00044 if self.rc is None:
00045 self.__arg = userArgText()
00046 self.__cnt = self.__arg.getValue(caption)
00047 else:
00048 self.__arg = self.rc.createGUI(userArgument, self.rc, 'test1', 1)
00049 self.__cnt = self.rc.execGUImethod(self.__arg.getValue, caption)
00050
00051 def run(self):
00052 log.debug("%s run" % self.getName())
00053 for i in xrange(self.__cnt):
00054 if self.isStopRequested(): break
00055 time.sleep(.1)
00056 log.info("%d" % i)
00057
00058 def stopRun(self):
00059 log.debug("%s stopRun" % self.getName())
00060
00061 def abort(self):
00062 log.debug("%s abort" % self.getName())
00063
00064
00065
00066
00067 class userArgument(ArgumentImpl):
00068 "GUI for getting the user to input some sort of value."
00069 def __init__(self, parent = None, name = None, modal = 0, fl = 0):
00070 ArgumentImpl.__init__(self, parent, name, modal, fl)
00071 self.__value = 0
00072 self.setCaption("Hello world!")
00073
00074 def OKButtonClicked(self):
00075 self.__value = int(self.ArgumentList.text().latin1())
00076 self.close()
00077
00078 def CancelButtonClicked(self):
00079 self.__value = None
00080 self.close()
00081
00082 def getValue(self, caption):
00083 self.setCaption(caption)
00084 self.show()
00085 self.exec_loop()
00086 return self.__value
00087
00088 class userArgText(object):
00089 "Text user interface for getting the user to input some sort of value"
00090 def __init__(self):
00091 pass
00092
00093 def getValue(self, caption):
00094 return int(raw_input("%s: " % (caption)))