]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxFloatBar.py
1 from wxPython
.wx
import *
2 from wxPython
.lib
.floatbar
import *
7 class TestFloatBar(wxFrame
):
8 def __init__(self
, parent
, log
):
9 wxFrame
.__init
__(self
, parent
, -1, 'Test ToolBar',
10 wxPoint(0,0), wxSize(500, 300))
13 win
= wxWindow(self
, -1)
14 win
.SetBackgroundColour(wxNamedColour("WHITE"))
15 wxStaticText(win
, -1, "Drag the toolbar to float it,\n"
16 "Toggle the last tool to remove\nthe title.", wxPoint(15,15))
18 tb
= wxFloatBar(self
, -1)
21 tb
.SetTitle("Floating!")
22 self
.CreateStatusBar()
24 tb
.AddSimpleTool(10, images
.getNewBitmap(), "New", "Long help for 'New'")
25 EVT_TOOL(self
, 10, self
.OnToolClick
)
26 EVT_TOOL_RCLICKED(self
, 10, self
.OnToolRClick
)
28 tb
.AddSimpleTool(20, images
.getOpenBitmap(), "Open")
29 EVT_TOOL(self
, 20, self
.OnToolClick
)
30 EVT_TOOL_RCLICKED(self
, 20, self
.OnToolRClick
)
33 tb
.AddSimpleTool(30, images
.getCopyBitmap(), "Copy")
34 EVT_TOOL(self
, 30, self
.OnToolClick
)
35 EVT_TOOL_RCLICKED(self
, 30, self
.OnToolRClick
)
37 tb
.AddSimpleTool(40, images
.getPasteBitmap(), "Paste")
38 EVT_TOOL(self
, 40, self
.OnToolClick
)
39 EVT_TOOL_RCLICKED(self
, 40, self
.OnToolRClick
)
44 tb
.AddTool(60, images
.getTog1Bitmap(), images
.getTog2Bitmap(),
45 shortHelpString
="Toggle with 2 bitmaps", isToggle
=true
)
46 EVT_TOOL(self
, 60, self
.OnToolClick
)
47 EVT_TOOL_RCLICKED(self
, 60, self
.OnToolRClick
)
51 EVT_CLOSE(self
, self
.OnCloseWindow
)
54 def OnCloseWindow(self
, event
):
57 def OnToolClick(self
, event
):
58 self
.log
.WriteText("tool %s clicked\n" % event
.GetId())
59 if event
.GetId() == 60:
60 print event
.GetExtraLong(), event
.Checked(), event
.GetInt(), self
.tb
.GetToolState(60)
61 if event
.GetExtraLong():
64 self
.tb
.SetTitle("Floating!")
66 def OnToolRClick(self
, event
):
67 self
.log
.WriteText("tool %s right-clicked\n" % event
.GetId())
68 # def test(self, event):
69 # self.log.WriteText("Button clicked!")
71 #---------------------------------------------------------------------------
73 def runTest(frame
, nb
, log
):
74 win
= TestFloatBar(frame
, log
)
78 #---------------------------------------------------------------------------
81 wxFloatBar is a subclass of wxToolBar, implemented in Python, which can be detached from its frame.
83 Drag the toolbar with the mouse to make it float, and drag it back, or close it to make the toolbar return to its original position.