Module speechViewer
[hide private]
[frames] | no frames]

Source Code for Module speechViewer

 1  #speechViewer.py 
 2  #A part of NonVisual Desktop Access (NVDA) 
 3  #Copyright (C) 2006-2008 NVDA Contributors <http://www.nvda-project.org/> 
 4  #This file is covered by the GNU General Public License. 
 5  #See the file COPYING for more details. 
 6   
 7  import wx 
 8  import gui 
 9   
10 -class SpeechViewerFrame(wx.MiniFrame):
11
12 - def __init__(self):
13 super(SpeechViewerFrame, self).__init__(gui.mainFrame, wx.ID_ANY, _("NVDA Speech Viewer"), style=wx.CAPTION | wx.RESIZE_BORDER | wx.STAY_ON_TOP) 14 self.Bind(wx.EVT_CLOSE, self.onClose) 15 sizer = wx.BoxSizer(wx.VERTICAL) 16 self.textCtrl = wx.TextCtrl(self, -1,size=(500,500),style=wx.TE_RICH2|wx.TE_READONLY|wx.TE_MULTILINE) 17 sizer.Add(self.textCtrl, proportion=1, flag=wx.EXPAND) 18 sizer.Fit(self) 19 self.SetSizer(sizer) 20 self.Show(True)
21
22 - def onClose(self, evt):
23 deactivate() 24 return 25 if not evt.CanVeto(): 26 self.Destroy() 27 return 28 evt.Veto()
29 30 _guiFrame=None 31 isActive=False 32
33 -def activate():
34 global _guiFrame, isActive 35 _guiFrame = SpeechViewerFrame() 36 isActive=True
37
38 -def appendText(text):
39 if not isActive: 40 return 41 if not isinstance(text,basestring): 42 return 43 #If the speech viewer text control has the focus, we want to disable updates 44 #Otherwize it would be impossible to select text, or even just read it (as a blind person). 45 if _guiFrame.FindFocus()==_guiFrame.textCtrl: 46 return 47 _guiFrame.textCtrl.AppendText(text + "\n")
48
49 -def deactivate():
50 global _guiFrame, isActive 51 if not isActive: 52 return 53 isActive=False 54 _guiFrame.Destroy() 55 _guiFrame = None
56