]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/MiniFrame.py
Don't decref if the interpreter is not initialized, (eg. it's in its
[wxWidgets.git] / wxPython / demo / MiniFrame.py
1
2 import wx
3
4 #---------------------------------------------------------------------------
5 class MyMiniFrame(wx.MiniFrame):
6 def __init__(
7 self, parent, title, pos=wx.DefaultPosition, size=wx.DefaultSize,
8 style=wx.DEFAULT_FRAME_STYLE
9 ):
10
11 wx.MiniFrame.__init__(self, parent, -1, title, pos, size, style)
12 panel = wx.Panel(self, -1)
13
14 button = wx.Button(panel, -1, "Close Me")
15 button.SetPosition((15, 15))
16 self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button)
17 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
18
19 def OnCloseMe(self, event):
20 self.Close(True)
21
22 def OnCloseWindow(self, event):
23 print "OnCloseWindow"
24 self.Destroy()
25
26 #---------------------------------------------------------------------------
27
28 class TestPanel(wx.Panel):
29 def __init__(self, parent, log):
30 self.log = log
31 wx.Panel.__init__(self, parent, -1)
32
33 b = wx.Button(self, -1, "Create and Show a MiniFrame", (50,50))
34 self.Bind(wx.EVT_BUTTON, self.OnButton, b)
35
36
37 def OnButton(self, evt):
38 win = MyMiniFrame(self, "This is a wx.MiniFrame",
39 style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ)
40 win.SetSize((200, 200))
41 win.CenterOnParent(wx.BOTH)
42 win.Show(True)
43
44
45 #---------------------------------------------------------------------------
46
47
48 def runTest(frame, nb, log):
49 win = TestPanel(nb, log)
50 return win
51
52
53 #---------------------------------------------------------------------------
54
55
56 overview = """\
57 A MiniFrame is a Frame with a small title bar. It is suitable for floating
58 toolbars that must not take up too much screen area. In other respects, it's the
59 same as a wx.Frame.
60 """
61
62
63 if __name__ == '__main__':
64 import sys,os
65 import run
66 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])