testAppInput.py

Go to the documentation of this file.
00001 #!/usr/local/bin/python
00002 #
00003 #                               Copyright 2005
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__ = "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       #self.rc.execGUImethod(self.__arg.deleteLater)
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 #  This class puts up a GUI for inputting a value of some sort.  It is used by
00066 #  the userApplication example to get the number of self triggers to take.
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)))

Generated on Thu Apr 27 20:52:44 2006 for LICOS L02-01-00 by doxygen 1.4.6-NO