]>
Commit | Line | Data |
---|---|---|
cbfc9df6 RD |
1 | import wx |
2 | print wx.VERSION | |
3 | ||
4 | ||
5 | class Frame(wx.Frame): | |
6 | def __init__(self, *args, **kw): | |
7 | wx.Frame.__init__(self, *args, **kw) | |
8 | self.log = wx.LogWindow(self, "Program Log", False, False) | |
9 | ||
10 | pnl = wx.Panel(self) | |
11 | btn1 = wx.Button(pnl, -1, "Toggle Log") | |
12 | btn2 = wx.Button(pnl, -1, "Log Message") | |
13 | btn3 = wx.Button(pnl, -1, "Close") | |
14 | ||
15 | sizer = wx.BoxSizer(wx.VERTICAL) | |
16 | sizer.Add(btn1, 0, wx.ALL, 10) | |
17 | sizer.Add(btn2, 0, wx.ALL, 10) | |
18 | sizer.Add(btn3, 0, wx.ALL, 10) | |
19 | pnl.SetSizer(sizer) | |
20 | ||
21 | self.Bind(wx.EVT_BUTTON, self.OnToggleLog, btn1) | |
22 | self.Bind(wx.EVT_BUTTON, self.OnLogMessage, btn2) | |
23 | self.Bind(wx.EVT_BUTTON, self.OnDoClose, btn3) | |
24 | self.Bind(wx.EVT_CLOSE, self.OnClose) | |
25 | ||
26 | ||
27 | def OnClose(self, evt): | |
28 | self.log.this.disown() | |
29 | wx.Log.SetActiveTarget(None) | |
30 | self.Destroy() | |
31 | ||
32 | ||
33 | def OnToggleLog(self, evt): | |
34 | self.log.Show(not self.log.GetFrame().IsShown()) | |
35 | ||
36 | def OnLogMessage(self, evt): | |
37 | wx.LogMessage("This is a test message") | |
38 | ||
39 | def OnDoClose(self, evt): | |
40 | self.Close() | |
41 | ||
42 | ||
43 | app = wx.App(False) | |
44 | frm = Frame(None, title="Testing wx.LogWindow") | |
45 | frm.Show() | |
46 | app.MainLoop() | |
47 |