]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxFloatBar.py
1 # 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net)
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.
7 # 11/28/2003 - Jeff Grimmett (grimmtooth@softhome.net)
9 # o Issues - library has to be converted to work properly
12 # 12/18/2003 - Jeff Grimmett (grimmtooth@softhome.net)
14 # o wxFloatBar -> FloatBar
18 import wx
.lib
.floatbar
23 class TestFloatBar(wx
.Frame
):
24 def __init__(self
, parent
, log
):
26 self
, parent
, -1, 'Test ToolBar', wx
.DefaultPosition
, (500, 300)
31 win
= wx
.Window(self
, -1)
32 win
.SetBackgroundColour("WHITE")
34 win
, -1, "Drag the toolbar to float it,\n"
35 "Toggle the last tool to remove\nthe title.", (15,15)
38 tb
= wx
.lib
.floatbar
.FloatBar(self
, -1)
41 tb
.SetTitle("Floating!")
42 self
.CreateStatusBar()
44 tb
.AddSimpleTool(10, images
.getNewBitmap(), "New", "Long help for 'New'")
45 self
.Bind(wx
.EVT_TOOL
, self
.OnToolClick
, id=10)
46 self
.Bind(wx
.EVT_TOOL_RCLICKED
, self
.OnToolRClick
, id=10)
48 tb
.AddSimpleTool(20, images
.getOpenBitmap(), "Open")
49 self
.Bind(wx
.EVT_TOOL
, self
.OnToolClick
, id=20)
50 self
.Bind(wx
.EVT_TOOL_RCLICKED
, self
.OnToolRClick
, id=20)
53 tb
.AddSimpleTool(30, images
.getCopyBitmap(), "Copy")
54 self
.Bind(wx
.EVT_TOOL
, self
.OnToolClick
, id=30)
55 self
.Bind(wx
.EVT_TOOL_RCLICKED
, self
.OnToolRClick
, id=30)
57 tb
.AddSimpleTool(40, images
.getPasteBitmap(), "Paste")
58 self
.Bind(wx
.EVT_TOOL
, self
.OnToolClick
, id=40)
59 self
.Bind(wx
.EVT_TOOL_RCLICKED
, self
.OnToolRClick
, id=40)
63 tb
.AddCheckTool(60, images
.getTog1Bitmap(), images
.getTog2Bitmap())
64 self
.Bind(wx
.EVT_TOOL
, self
.OnToolClick
, id=60)
65 self
.Bind(wx
.EVT_TOOL_RCLICKED
, self
.OnToolRClick
, id=60)
70 self
.Bind(wx
.EVT_CLOSE
, self
.OnCloseWindow
)
73 def OnCloseWindow(self
, event
):
76 def OnToolClick(self
, event
):
77 self
.log
.WriteText("tool %s clicked\n" % event
.GetId())
79 if event
.GetId() == 60:
80 print event
.GetExtraLong(), event
.IsChecked(), event
.GetInt(), self
.tb
.GetToolState(60)
82 if event
.GetExtraLong():
85 self
.tb
.SetTitle("Floating!")
87 def OnToolRClick(self
, event
):
88 self
.log
.WriteText("tool %s right-clicked\n" % event
.GetId())
90 #---------------------------------------------------------------------------
92 def runTest(frame
, nb
, log
):
93 win
= TestFloatBar(frame
, log
)
97 #---------------------------------------------------------------------------
100 FloatBar is a subclass of wx.ToolBar, implemented in Python, which
101 can be detached from its frame.
103 Drag the toolbar with the mouse to make it float, and drag it back, or
104 close it to make the toolbar return to its original position.
108 if __name__
== '__main__':
111 run
.main(['', os
.path
.basename(sys
.argv
[0])])