gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nicola...@apache.org
Subject cvs commit: jakarta-gump/python/gump view.py
Date Mon, 05 May 2003 08:25:13 GMT
nicolaken    2003/05/05 01:25:12

  Modified:    python/gump view.py
  Log:
  Simple but working log viewing in the GUI
  
  Revision  Changes    Path
  1.26      +37 -1     jakarta-gump/python/gump/view.py
  
  Index: view.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/view.py,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- view.py	5 May 2003 07:54:35 -0000	1.25
  +++ view.py	5 May 2003 08:25:12 -0000	1.26
  @@ -404,6 +404,27 @@
       dlg.ShowModal()
       dlg.Destroy()
   
  +class ViewHandler(logging.Handler):
  +
  +    view = None
  +
  +    """
  +    A handler class which logs in this view .
  +    """    
  +    def __init__(self, logview):
  +        """
  +        Initializes the handler
  +        """
  +        logging.Handler.__init__(self)
  +        self.view = logview
  +        
  +    def emit(self, record):
  +        """
  +        Emit a record.
  +        """
  +        msg = "%s\n" % self.format(record)
  +        self.view.AppendText(msg)
  +        
   class GumpSplashScreen(wxSplashScreen):
     def __init__(self):
       bmp = wxImage("gump/images/gump.bmp").ConvertToBitmap()
  @@ -443,9 +464,24 @@
       self.view.showProject(self.project)
   
   if __name__ == '__main__':
  -  logging.config.fileConfig("gump/logconf.ini") 
  +
  +  # init logging and add specific Gui handler
  +  logging.config.fileConfig("gump/logconf.ini")
  +  
  +  # load app
     app = gumpview(0)
     GumpSplashScreen().Show()
  +
  +  #add app-specific log handler
  +  logger = logging.getLogger("")
  +  lh = ViewHandler(app.logview)
  +  logger.addHandler(lh)
  +  
  +  # loadspecified or default workspace
     app.load(sys.argv[1:] or [default.workspace])
  +
  +  # start app
     app.MainLoop()
  +
  +  # dipose app
     app.unload()
  
  
  

Mime
View raw message