]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/FloatBar.py
2 # Please note that wx.lib.floatbar is not formally supported as
3 # part of wxPython. If it works, fine. If not, unfortunate.
4 # GTK users can use the wx.TB_DOCKABLE flag with a regular
5 # wx.ToolBar, but everyone else has to take thier chances.
14 class TestFloatBar(wx
.Frame
):
15 def __init__(self
, parent
, log
):
17 self
, parent
, -1, 'Test ToolBar', wx
.DefaultPosition
, (500, 300)
22 win
= wx
.Window(self
, -1)
23 win
.SetBackgroundColour("WHITE")
25 win
, -1, "Drag the toolbar to float it,\n"
26 "Toggle the last tool to remove\nthe title.", (15,15)
29 tb
= wx
.lib
.floatbar
.FloatBar(self
, -1)
32 tb
.SetTitle("Floating!")
33 self
.CreateStatusBar()
35 tb
.AddSimpleTool(10, images
.getNewBitmap(), "New", "Long help for 'New'")
36 self
.Bind(wx
.EVT_TOOL
, self
.OnToolClick
, id=10)
37 self
.Bind(wx
.EVT_TOOL_RCLICKED
, self
.OnToolRClick
, id=10)
39 tb
.AddSimpleTool(20, images
.getOpenBitmap(), "Open")
40 self
.Bind(wx
.EVT_TOOL
, self
.OnToolClick
, id=20)
41 self
.Bind(wx
.EVT_TOOL_RCLICKED
, self
.OnToolRClick
, id=20)
44 tb
.AddSimpleTool(30, images
.getCopyBitmap(), "Copy")
45 self
.Bind(wx
.EVT_TOOL
, self
.OnToolClick
, id=30)
46 self
.Bind(wx
.EVT_TOOL_RCLICKED
, self
.OnToolRClick
, id=30)
48 tb
.AddSimpleTool(40, images
.getPasteBitmap(), "Paste")
49 self
.Bind(wx
.EVT_TOOL
, self
.OnToolClick
, id=40)
50 self
.Bind(wx
.EVT_TOOL_RCLICKED
, self
.OnToolRClick
, id=40)
54 tb
.AddCheckTool(60, images
.getTog1Bitmap(), images
.getTog2Bitmap())
55 self
.Bind(wx
.EVT_TOOL
, self
.OnToolClick
, id=60)
56 self
.Bind(wx
.EVT_TOOL_RCLICKED
, self
.OnToolRClick
, id=60)
61 self
.Bind(wx
.EVT_CLOSE
, self
.OnCloseWindow
)
64 def OnCloseWindow(self
, event
):
67 def OnToolClick(self
, event
):
68 self
.log
.WriteText("tool %s clicked\n" % event
.GetId())
70 if event
.GetId() == 60:
71 print event
.GetExtraLong(), event
.IsChecked(), event
.GetInt(), self
.tb
.GetToolState(60)
73 if event
.GetExtraLong():
76 self
.tb
.SetTitle("Floating!")
78 def OnToolRClick(self
, event
):
79 self
.log
.WriteText("tool %s right-clicked\n" % event
.GetId())
81 #---------------------------------------------------------------------------
83 def runTest(frame
, nb
, log
):
84 if wx
.Platform
== "__WXMAC__":
85 dlg
= wx
.MessageDialog(
86 frame
, 'FloatBar does not work well on this platform.',
87 'Sorry', wx
.OK | wx
.ICON_INFORMATION
92 win
= TestFloatBar(frame
, log
)
96 #---------------------------------------------------------------------------
99 FloatBar is a subclass of wx.ToolBar, implemented in Python, which
100 can be detached from its frame.
102 Drag the toolbar with the mouse to make it float, and drag it back, or
103 close it to make the toolbar return to its original position.
107 if __name__
== '__main__':
110 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])