[Nvda-dev] commit r1949 - in trunk: . source/gui

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Nvda-dev] commit r1949 - in trunk: . source/gui

NVDA Subversion
Author: jteh
Date: Tue Apr 22 23:46:21 2008
New Revision: 1949

Log:
Provide the ability to view the NVDA log from within NVDA. This is accessible via NVDA menu->Tools->View log.

Added:
   trunk/source/gui/logViewer.py   (contents, props changed)
Modified:
   trunk/   (props changed)
   trunk/source/gui/__init__.py

Modified: trunk/source/gui/__init__.py
==============================================================================
--- trunk/source/gui/__init__.py (original)
+++ trunk/source/gui/__init__.py Tue Apr 22 23:46:21 2008
@@ -18,6 +18,7 @@
 from settingsDialogs import *
 import speechDictHandler
 import languageHandler
+import logViewer
 
 ### Constants
 appTitle = "NVDA"
@@ -198,6 +199,9 @@
  except:
  globalVars.log.error("gui.mainFrame.onAbout", exc_info=True)
 
+ def onViewLogCommand(self, evt):
+ logViewer.LogViewer().Show()
+
 class SysTrayIcon(wx.TaskBarIcon):
 
  def __init__(self, frame):
@@ -233,6 +237,11 @@
  menu_preferences.AppendMenu(wx.ID_ANY,_("Speech &dictionaries"),subMenu_speechDicts)
  self.menu.AppendMenu(wx.ID_ANY,_("&Preferences"),menu_preferences)
 
+ menu_tools = wx.Menu()
+ item = menu_tools.Append(wx.ID_ANY, _("View log"))
+ self.Bind(wx.EVT_MENU, frame.onViewLogCommand, item)
+ self.menu.AppendMenu(wx.ID_ANY, _("Tools"), menu_tools)
+
  menu_help = wx.Menu()
  item = menu_help.Append(wx.ID_ANY, _("User guide"))
  self.Bind(wx.EVT_MENU, lambda evt: os.startfile(getDocFilePath("user guide.html")), item)

Added: trunk/source/gui/logViewer.py
==============================================================================
--- (empty file)
+++ trunk/source/gui/logViewer.py Tue Apr 22 23:46:21 2008
@@ -0,0 +1,45 @@
+"""Provides functionality to view the NVDA log.
+"""
+
+import logging
+import wx
+import globalVars
+import gui
+
+class LogViewer(wx.Frame):
+ """The NVDA log viewer GUI.
+ """
+
+ def __init__(self):
+ super(LogViewer, self).__init__(None, wx.ID_ANY, _("NVDA Log Viewer"))
+ gui.topLevelWindows.append(self)
+ self.Bind(wx.EVT_CLOSE, self.onClose)
+ mainSizer = wx.BoxSizer(wx.VERTICAL)
+ self.outputCtrl = wx.TextCtrl(self, wx.ID_ANY, size=(500, 500), style=wx.TE_MULTILINE | wx.TE_READONLY)
+ mainSizer.Add(self.outputCtrl, proportion=1, flag=wx.EXPAND)
+ self.SetSizer(mainSizer)
+ mainSizer.Fit(self)
+
+ # Populate the output control with the contents of the log file.
+ try:
+ self.outputCtrl.SetValue(file(globalVars.appArgs.logFileName, "r").read())
+ except IOError:
+ pass
+
+ # Install a log handler to direct future output to the output control.
+ # wx.TextCtrl does not support flush(), so fudge it.
+ self.outputCtrl.flush = lambda: None
+ self.logHandler = logging.StreamHandler(self.outputCtrl)
+ self.logHandler.setFormatter(globalVars.log.handlers[0].formatter)
+ globalVars.log.addHandler(self.logHandler)
+
+ self.outputCtrl.SetFocus()
+
+ def onClose(self, evt):
+ self.Destroy()
+
+ def Destroy(self):
+ gui.topLevelWindows.remove(self)
+ globalVars.log.removeHandler(self.logHandler)
+ self.logHandler.close()
+ super(LogViewer, self).Destroy()