]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxFloatBar.py
1 from wxPython
.wx
import *
2 from wxPython
.lib
.floatbar
import *
4 class TestFloatBar(wxFrame
):
5 def __init__(self
, parent
, log
):
6 wxFrame
.__init
__(self
, parent
, -1, 'Test ToolBar',
7 wxPoint(0,0), wxSize(500, 300))
10 win
= wxWindow(self
, -1)
11 win
.SetBackgroundColour(wxNamedColour("WHITE"))
12 wxStaticText(win
, -1, "Drag the toolbar to float it,\n"
13 "Toggle the last tool to remove\nthe title.", wxPoint(15,15))
15 tb
= wxFloatBar(self
, -1)
18 tb
.SetTitle("Floating!")
19 self
.CreateStatusBar()
20 tb
.AddSimpleTool(10, wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP
),
21 "New", "Long help for 'New'")
22 EVT_TOOL(self
, 10, self
.OnToolClick
)
23 EVT_TOOL_RCLICKED(self
, 10, self
.OnToolRClick
)
25 tb
.AddSimpleTool(20, wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP
),
27 EVT_TOOL(self
, 20, self
.OnToolClick
)
28 EVT_TOOL_RCLICKED(self
, 20, self
.OnToolRClick
)
31 tb
.AddSimpleTool(30, wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP
),
33 EVT_TOOL(self
, 30, self
.OnToolClick
)
34 EVT_TOOL_RCLICKED(self
, 30, self
.OnToolRClick
)
36 tb
.AddSimpleTool(40, wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP
),
38 EVT_TOOL(self
, 40, self
.OnToolClick
)
39 EVT_TOOL_RCLICKED(self
, 40, self
.OnToolRClick
)
44 tb
.AddTool(60, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP
),
45 wxBitmap('bitmaps/tog2.bmp', wxBITMAP_TYPE_BMP
),
46 shortHelpString
="Toggle with 2 bitmaps", isToggle
=true
)
47 EVT_TOOL(self
, 60, self
.OnToolClick
)
48 EVT_TOOL_RCLICKED(self
, 60, self
.OnToolRClick
)
52 EVT_CLOSE(self
, self
.OnCloseWindow
)
55 def OnCloseWindow(self
, event
):
58 def OnToolClick(self
, event
):
59 self
.log
.WriteText("tool %s clicked\n" % event
.GetId())
60 if event
.GetId() == 60:
61 print event
.GetExtraLong(), event
.Checked(), event
.GetInt(), self
.tb
.GetToolState(60)
62 if event
.GetExtraLong():
65 self
.tb
.SetTitle("Floating!")
67 def OnToolRClick(self
, event
):
68 self
.log
.WriteText("tool %s right-clicked\n" % event
.GetId())
69 # def test(self, event):
70 # self.log.WriteText("Button clicked!")
72 #---------------------------------------------------------------------------
74 def runTest(frame
, nb
, log
):
75 win
= TestFloatBar(frame
, log
)
79 #---------------------------------------------------------------------------
82 wxFloatBar is a subclass of wxToolBar, implemented in Python, which can be detached from its frame.
84 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.