关于wxpython中使用logging模块输出日志的问题
请求下各位,wxpython中,如何使用logging模块将日志信息输出到图形界面的指定文本框里,最好来个例子,嘿嘿,本人初学python不久,还请不吝赐教
[解决办法]
忘了说,wx也有自己的logging...
#~ import logging
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title)
self.textctrl = wx.TextCtrl(self, style=wx.TE_MULTILINE)
wx.CallAfter(self.dologging)
self.Show()
def write(self, s):
self.textctrl.AppendText(s)
def dologging(self):
print 'do logging...'
#~ logging.warning('This message should go to my wxTextCtrl...')
wx.LogMessage('This message should go to my wxTextCtrl...')
wx.CallLater(3000, self.dologging)
app = wx.App(False)
frame = MyFrame(None, 'logging demo')
#~ logging.basicConfig(stream=frame)
wx.Log.SetActiveTarget(wx.LogTextCtrl(frame.textctrl))
app.MainLoop()