#!/usr/bin/python
import wx
import os
import sys
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(480, 400))
self.panel = MyPanel(self, -1)
self.Centre()
self.Show(True)
setstd()
print 'test'
"""
syncall()
"""
class MyPanel(wx.Panel):
def __init__(self, parent, id):
wx.Panel.__init__(self, parent, id)
self.text = wx.StaticText(self, -1, '', (40, 60))
class MyText():
def write(string):
label = frame.panel.text.GetLabel()
frame.panel.text.SetLabel(string)
def setstd():
sys.stdout = MyText()
sys.stderr = MyText()
app = wx.App()
frame = MyFrame(None, -1, 'DropBox log')
app.MainLoop()
Without print 'test', it even runs, but with print 'test', it doesn't run nor redirect output.
How to redirect standard output to print messages in gui instead of terminal?