Browse Source

Creating own log window to capture logs from wx.Log

Gyedo Jeon 15 years ago
parent
commit
ddf0022ff3
1 changed files with 10 additions and 2 deletions
  1. 10 2
      direct/src/wxwidgets/WxAppShell.py

+ 10 - 2
direct/src/wxwidgets/WxAppShell.py

@@ -29,13 +29,14 @@ class WxAppShell(wx.Frame):
             kw['size'] = wx.Size(self.frameWidth, self.frameHeight)
         wx.Frame.__init__(self, None, -1, *args, **kw)
 
+        self._logWin = None
         # Initialize the application
         self.appInit()
-
         self.__createInterface()
         self.Show()
         
     def __createInterface(self):
+        self.__createLogWin()
         self.__createMenuBar()
         self.__createAboutBox()
         # Add binding for panel cleanup code
@@ -47,6 +48,14 @@ class WxAppShell(wx.Frame):
         self.createMenuBar()
         self.createInterface()
 
+    def __createLogWin(self, evt=None):
+        # to bypass wx.Log
+        if self._logWin:
+            self._logWin.Destroy()
+        self._logWin = wx.Frame(None)
+        self._logWin.Bind(wx.EVT_CLOSE, self.__createLogWin)
+        wx.Log.SetActiveTarget(wx.LogTextCtrl(wx.TextCtrl(self._logWin, style=wx.TE_MULTILINE)))
+
     def __createMenuBar(self):
         self.menuBar = wx.MenuBar()
         self.SetMenuBar(self.menuBar)
@@ -103,4 +112,3 @@ class WxAppShell(wx.Frame):
 
         menuItem = self.menuHelp.Append(wx.ID_ABOUT, "&About...")
         self.Bind(wx.EVT_MENU, self.showAbout, menuItem)
-