Added wxPyLog so log targets can be created in Python with the

appropriate callbacks.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11851 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2001-10-05 18:29:29 +00:00
parent 72594e90b2
commit 76bfdc7816
9 changed files with 582 additions and 45 deletions

View File

@@ -11,7 +11,7 @@
# Licence: wxWindows license
#----------------------------------------------------------------------------
import sys, os
import sys, os, time
from wxPython.wx import *
from wxPython.lib.splashscreen import SplashScreen
from wxPython.html import wxHtmlWindow
@@ -74,6 +74,21 @@ _treeList = [
#---------------------------------------------------------------------------
class MyLog(wxPyLog):
def __init__(self, textCtrl, logTime=0):
wxPyLog.__init__(self)
self.tc = textCtrl
self.logTime = logTime
def DoLogString(self, message, timeStamp):
if self.logTime:
message = time.strftime("%X", time.localtime(timeStamp)) + \
": " + message
self.tc.AppendText(message + '\n')
#---------------------------------------------------------------------------
class wxPythonDemo(wxFrame):
def __init__(self, parent, id, title):
@@ -217,7 +232,8 @@ class wxPythonDemo(wxFrame):
self.log = wxTextCtrl(splitter2, -1,
style = wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL)
# Set the wxWindows log target to be this textctrl
wxLog_SetActiveTarget(wxLogTextCtrl(self.log))
#wxLog_SetActiveTarget(wxLogTextCtrl(self.log))
wxLog_SetActiveTarget(MyLog(self.log))