V
vedrandekovic
Hello,
Why this wx example don't return \nHELLO WORLD and other text in same
window:
import wx
import logging
import sys
def nekaj():
print "\nHELLO WORLD"
class WxLog(logging.Handler):
def __init__(self, ctrl):
logging.Handler.__init__(self)
self.ctrl = ctrl
def emit(self, record):
self.ctrl.AppendText(self.format(record)+"\n")
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="logging test")
sizer = wx.BoxSizer(wx.VERTICAL)
log = wx.TextCtrl(self, style=wx.TE_MULTILINE)
rootLogger = logging.getLogger('')
rootLogger.setLevel(logging.DEBUG)
hdlr = WxLog(log)
hdlr.setFormatter(logging.Formatter('%(levelname)s | %(name)s |
%(message)s [@ %(asctime)s in %(filename)s:%(lineno)d]'))
rootLogger.addHandler(hdlr)
rootLogger.debug(str(sys.stdout))
nekaj() # goes to the function nekaj
if __name__ =="__main__":
app = wx.App(0)
frame = MainFrame()
frame.Show()
app.MainLoop()
Regards,
Vedran
Why this wx example don't return \nHELLO WORLD and other text in same
window:
import wx
import logging
import sys
def nekaj():
print "\nHELLO WORLD"
class WxLog(logging.Handler):
def __init__(self, ctrl):
logging.Handler.__init__(self)
self.ctrl = ctrl
def emit(self, record):
self.ctrl.AppendText(self.format(record)+"\n")
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="logging test")
sizer = wx.BoxSizer(wx.VERTICAL)
log = wx.TextCtrl(self, style=wx.TE_MULTILINE)
rootLogger = logging.getLogger('')
rootLogger.setLevel(logging.DEBUG)
hdlr = WxLog(log)
hdlr.setFormatter(logging.Formatter('%(levelname)s | %(name)s |
%(message)s [@ %(asctime)s in %(filename)s:%(lineno)d]'))
rootLogger.addHandler(hdlr)
rootLogger.debug(str(sys.stdout))
nekaj() # goes to the function nekaj
if __name__ =="__main__":
app = wx.App(0)
frame = MainFrame()
frame.Show()
app.MainLoop()
Regards,
Vedran