]>
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
14 import wx
.lib
.floatbar
as float
19 class TestFloatBar(wx
.Frame
):
20 def __init__(self
, parent
, log
):
22 self
, parent
, -1, 'Test ToolBar', wx
.DefaultPosition
, (500, 300)
27 win
= wx
.Window(self
, -1)
28 win
.SetBackgroundColour("WHITE")
30 win
, -1, "Drag the toolbar to float it,\n"
31 "Toggle the last tool to remove\nthe title.", (15,15)
34 tb
= float.wxFloatBar(self
, -1)
37 tb
.SetTitle("Floating!")
38 self
.CreateStatusBar()
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)
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)
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)
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)
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)
66 self
.Bind(wx
.EVT_CLOSE
, self
.OnCloseWindow
)
69 def OnCloseWindow(self
, event
):
72 def OnToolClick(self
, event
):
73 self
.log
.WriteText("tool %s clicked\n" % event
.GetId())
75 if event
.GetId() == 60:
76 print event
.GetExtraLong(), event
.Checked(), event
.GetInt(), self
.tb
.GetToolState(60)
78 if event
.GetExtraLong():
81 self
.tb
.SetTitle("Floating!")
83 def OnToolRClick(self
, event
):
84 self
.log
.WriteText("tool %s right-clicked\n" % event
.GetId())
86 #---------------------------------------------------------------------------
88 def runTest(frame
, nb
, log
):
89 win
= TestFloatBar(frame
, log
)
93 #---------------------------------------------------------------------------
96 wxFloatBar is a subclass of wxToolBar, implemented in Python, which
97 can be detached from its frame.
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.
104 if __name__
== '__main__':
107 run
.main(['', os
.path
.basename(sys
.argv
[0])])