]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxFloatBar.py
Reworked how stock objects are initialized. They now have an
[wxWidgets.git] / wxPython / demo / wxFloatBar.py
1 # 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net)
2 #
3 # o Updated for wx namespace
4 # o OK, Main.py indicates this is deprecated. But I don't see a
5 # replacement yet. So conversion is done anyway.
6 #
7 # 11/28/2003 - Jeff Grimmett (grimmtooth@softhome.net)
8 #
9 # o Issues - library has to be converted to work properly
10 # with new namespace.
11 #
12
13 import wx
14 import wx.lib.floatbar as float
15
16 import images
17
18
19 class TestFloatBar(wx.Frame):
20 def __init__(self, parent, log):
21 wx.Frame.__init__(
22 self, parent, -1, 'Test ToolBar', wx.DefaultPosition, (500, 300)
23 )
24
25 self.log = log
26
27 win = wx.Window(self, -1)
28 win.SetBackgroundColour("WHITE")
29 wx.StaticText(
30 win, -1, "Drag the toolbar to float it,\n"
31 "Toggle the last tool to remove\nthe title.", (15,15)
32 )
33
34 tb = float.wxFloatBar(self, -1)
35 self.SetToolBar(tb)
36 tb.SetFloatable(1)
37 tb.SetTitle("Floating!")
38 self.CreateStatusBar()
39
40 tb.AddSimpleTool(10, images.getNewBitmap(), "New", "Long help for 'New'")
41 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=10)
42 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=10)
43
44 tb.AddSimpleTool(20, images.getOpenBitmap(), "Open")
45 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=20)
46 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=20)
47
48 tb.AddSeparator()
49 tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy")
50 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=30)
51 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=30)
52
53 tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste")
54 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=40)
55 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=40)
56
57 tb.AddSeparator()
58
59 tb.AddCheckTool(60, images.getTog1Bitmap(), images.getTog2Bitmap())
60 self.Bind(wx.EVT_TOOL, self.OnToolClick, id=60)
61 self.Bind(wx.EVT_TOOL_RCLICKED, self.OnToolRClick, id=60)
62
63 tb.Realize()
64
65 self.tb = tb
66 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
67
68
69 def OnCloseWindow(self, event):
70 self.Destroy()
71
72 def OnToolClick(self, event):
73 self.log.WriteText("tool %s clicked\n" % event.GetId())
74
75 if event.GetId() == 60:
76 print event.GetExtraLong(), event.Checked(), event.GetInt(), self.tb.GetToolState(60)
77
78 if event.GetExtraLong():
79 self.tb.SetTitle("")
80 else:
81 self.tb.SetTitle("Floating!")
82
83 def OnToolRClick(self, event):
84 self.log.WriteText("tool %s right-clicked\n" % event.GetId())
85
86 #---------------------------------------------------------------------------
87
88 def runTest(frame, nb, log):
89 win = TestFloatBar(frame, log)
90 frame.otherWin = win
91 win.Show(True)
92
93 #---------------------------------------------------------------------------
94
95 overview = """\
96 wxFloatBar is a subclass of wxToolBar, implemented in Python, which
97 can be detached from its frame.
98
99 Drag the toolbar with the mouse to make it float, and drag it back, or
100 close it to make the toolbar return to its original position.
101
102 """
103
104 if __name__ == '__main__':
105 import sys,os
106 import run
107 run.main(['', os.path.basename(sys.argv[0])])
108
109
110
111
112
113
114
115
116
117
118
119
120