ArgumentImpl.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 __author__   = "A. Kavelaars <aliciak@SLAC.Stanford.edu> SLAC - GLAST LAT I&T/Online"
00012 __abstract__ = "Argument GUI implementation module"
00013 __date__     = "2003/11/20 00:00:00"
00014 __updated__  = "$Date: 2005/09/21 23:54:51 $"
00015 __version__  = "$Revision: 1.4 $"
00016 __release__  = "$Name: HEAD $"
00017 __credits__  = "SLAC"
00018 
00019 import LICOS.copyright_SLAC
00020 
00021 import sys
00022 from qt import *
00023 from Argument import Argument
00024 
00025 
00026 class ArgumentImpl(Argument):
00027   """!\brief Generic class to provide an input dialog for operator input.
00028 
00029   """
00030   def __init__(self, parent = None,name = None, modal = 0, fl = 0):
00031     """!\brief ArgumentImpl constructor
00032 
00033     \param parent Parent GUI
00034     \param name   GUI name
00035     \param modal  Whether the dialog is modal or not
00036     \param fl     GUI flags
00037     """
00038     Argument.__init__(self,parent,name,modal,fl)
00039 
00040     self.__label = 0
00041 
00042     self.connect(self.OKButton,SIGNAL("clicked()"),self.OKButtonClicked)
00043     self.connect(self.CancelButton,SIGNAL("clicked()"),self.CancelButtonClicked)
00044 
00045   def OKButtonClicked(self):
00046     """!\brief Handle OK button click.
00047 
00048     """
00049     self.__value = int(self.ArgumentList.text().latin1())
00050     self.close()
00051 
00052   def getValue(self, caption, value = None):
00053     """!\brief Show the dialog box and wait for user input.
00054 
00055     \param caption Input dialog title
00056     \param value   Default value
00057 
00058     \return Input value
00059     """
00060     if value is not None:
00061       self.ArgumentList.setText(str(value))
00062     self.ArgLabel.setText(caption)
00063     self.show()
00064     self.exec_loop()
00065     return self.__value
00066 
00067   def CancelButtonClicked(self):
00068     """!\brief Handle Cancel button click.
00069 
00070     """
00071     self.close()
00072 
00073 if __name__ == "__main__":
00074     a = QApplication(sys.argv)
00075     QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
00076     w = ArgumentImpl()
00077     a.setMainWidget(w)
00078     w.show()
00079     a.exec_loop()

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