Confused with wx.PyLog.DoLogString

Hi,

In the wx demo, there is a class MyLog in the Main.py.

class MyLog(wx.PyLog):
     def __init__(self, textCtrl, logTime=0):
         wx.PyLog.__init__(self)
         self.tc = textCtrl
         self.logTime = logTime

     def DoLogString(self, message, timeStamp):
         if self.tc:
             self.tc.AppendText(message + '\n')

An instance of MyLog was then set as the default target of wxLog:
   wx.Log_SetActiveTarget(MyLog(self.log))

Here, it seems that the key of deriving from a wx.PyLog is to override DoLogString(...). But I cannot find the declaration of this function neither in the C++ wxWidget documentation, nor in wxPython API document. Where is it?

More strange thing is, in the wxPython API documentation, PyLog was described as "Proxy of C++ PyLog class". I think, in C++, there is no any wx*** class, right?

Thanks in advance.

···

--
narke
I can't go back to yesterday - because I was a different person then.

Hi,

In the wx demo, there is a class MyLog in the Main.py.

class MyLog(wx.PyLog):
def __init__(self, textCtrl, logTime=0):
wx.PyLog.__init__(self)
self.tc = textCtrl
self.logTime = logTime

def DoLogString(self, message, timeStamp):
if self.tc:
self.tc.AppendText(message + '\n')

An instance of MyLog was then set as the default target of wxLog:
wx.Log_SetActiveTarget(MyLog(self.log))

Here, it seems that the key of deriving from a wx.PyLog is to override
DoLogString(...). But I cannot find the declaration of this function
neither in the C++ wxWidget documentation, nor in wxPython API document.
Where is it?

http://docs.wxwidgets.org/2.8.12/wx_wxlog.html#wxlogdologstring

More strange thing is, in the wxPython API documentation, PyLog was
described as "Proxy of C++ PyLog class". I think, in C++, there is no
any wx*** class, right?

The PyFoo classes are usually specialized implementations of a C++ class derived from wxFoo that knows how to redirect calls to its virtual methods to Python methods of the same name in a derived class if there is one.

···

On 6/11/12 7:48 AM, narke wrote:

--
Robin Dunn
Software Craftsman

Hi,

In the wx demo, there is a class MyLog in the Main.py.

class MyLog(wx.PyLog):
def __init__(self, textCtrl, logTime=0):
wx.PyLog.__init__(self)
self.tc = textCtrl
self.logTime = logTime

def DoLogString(self, message, timeStamp):
if self.tc:
self.tc.AppendText(message + '\n')

An instance of MyLog was then set as the default target of wxLog:
wx.Log_SetActiveTarget(MyLog(self.log))

Here, it seems that the key of deriving from a wx.PyLog is to override
DoLogString(...). But I cannot find the declaration of this function
neither in the C++ wxWidget documentation, nor in wxPython API document.
Where is it?

wxLog

Thanks. I did not know it's in 2.8.12 doc. But in the trunk doc, there is no DoLogString in wxLog. However, there is a same name
method (with different arguments) in wxProtocolLog. Does it mean the DoLogString was removed from latest wxWidgets?

More strange thing is, in the wxPython API documentation, PyLog was
described as "Proxy of C++ PyLog class". I think, in C++, there is no
any wx*** class, right?

The PyFoo classes are usually specialized implementations of a C++ class
derived from wxFoo that knows how to redirect calls to its virtual
methods to Python methods of the same name in a derived class if there
is one.

Sorry, not fully understand. If, for a C++ class wxFoo, there exists two python classes, wxFoo and PyFoo, what's the relations between Python classes PyFoo and wxFoo? Here, the example is wxLog and PyLog? My understanding is that Python wxFoo corresponds to C++ wxFoo, but don't know to what C++ class the Python PyFoo correspond.

···

On 6/12/2012 3:12 AM, Robin Dunn wrote:

On 6/11/12 7:48 AM, narke wrote:

--
narke
I can't go back to yesterday - because I was a different person then.

Hi,

In the wx demo, there is a class MyLog in the Main.py.

class MyLog(wx.PyLog):
def __init__(self, textCtrl, logTime=0):
wx.PyLog.__init__(self)
self.tc = textCtrl
self.logTime = logTime

def DoLogString(self, message, timeStamp):
if self.tc:
self.tc.AppendText(message + '\n')

An instance of MyLog was then set as the default target of wxLog:
wx.Log_SetActiveTarget(MyLog(self.log))

Here, it seems that the key of deriving from a wx.PyLog is to override
DoLogString(...). But I cannot find the declaration of this function
neither in the C++ wxWidget documentation, nor in wxPython API document.
Where is it?

wxLog

Thanks. I did not know it's in 2.8.12 doc. But in the trunk doc, there
is no DoLogString in wxLog. However, there is a same name
method (with different arguments) in wxProtocolLog. Does it mean the
DoLogString was removed from latest wxWidgets?

It is still there but undocumented. New code should use one of
DoLogRecord, DoLogTextAtLevel, or DoLogText. See wxWidgets: wxLog Class Reference

More strange thing is, in the wxPython API documentation, PyLog was
described as "Proxy of C++ PyLog class". I think, in C++, there is no
any wx*** class, right?

The PyFoo classes are usually specialized implementations of a C++ class
derived from wxFoo that knows how to redirect calls to its virtual
methods to Python methods of the same name in a derived class if there
is one.

Sorry, not fully understand. If, for a C++ class wxFoo, there exists two
python classes, wxFoo and PyFoo, what's the relations between Python
classes PyFoo and wxFoo? Here, the example is wxLog and PyLog? My
understanding is that Python wxFoo corresponds to C++ wxFoo, but don't
know to what C++ class the Python PyFoo correspond.

It is a C++ class derived from wxLog which has overloads in place that understand Python classes and are able to reflect calls to those C++ methods to the Python version of the methods. It is also wrapped by wxPython so you can create instances of it from Python code. See OverridingMethods - wxPyWiki (especially 3rd paragraph)

···

On 6/11/12 6:29 PM, narke wrote:

On 6/12/2012 3:12 AM, Robin Dunn wrote:

On 6/11/12 7:48 AM, narke wrote:

--
Robin Dunn
Software Craftsman