]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxFloatBar.py
Added SetOrderByColNums() function
[wxWidgets.git] / wxPython / demo / wxFloatBar.py
CommitLineData
f0261a72
RD
1from wxPython.wx import *
2from wxPython.lib.floatbar import *
3
4class TestFloatBar(wxFrame):
5 def __init__(self, parent, log):
6 wxFrame.__init__(self, parent, -1, 'Test ToolBar',
7 wxPoint(0,0), wxSize(500, 300))
8 self.log = log
9
944930d5
RD
10 win = wxWindow(self, -1)
11 win.SetBackgroundColour(wxNamedColour("WHITE"))
12 wxStaticText(win, -1, "Drag the toolbar to float it,\n"
b7e72427 13 "Toggle the last tool to remove\nthe title.", wxPoint(15,15))
f0261a72
RD
14
15 tb = wxFloatBar(self, -1)
16 self.SetToolBar(tb)
17 tb.SetFloatable(1)
18 tb.SetTitle("Floating!")
19 self.CreateStatusBar()
1b55cabf
RD
20 tb.AddSimpleTool(10, wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP),
21 "New", "Long help for 'New'")
f0261a72
RD
22 EVT_TOOL(self, 10, self.OnToolClick)
23 EVT_TOOL_RCLICKED(self, 10, self.OnToolRClick)
24
1b55cabf
RD
25 tb.AddSimpleTool(20, wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP),
26 "Open")
f0261a72
RD
27 EVT_TOOL(self, 20, self.OnToolClick)
28 EVT_TOOL_RCLICKED(self, 20, self.OnToolRClick)
29
30 tb.AddSeparator()
1b55cabf
RD
31 tb.AddSimpleTool(30, wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP),
32 "Copy")
f0261a72
RD
33 EVT_TOOL(self, 30, self.OnToolClick)
34 EVT_TOOL_RCLICKED(self, 30, self.OnToolRClick)
35
1b55cabf
RD
36 tb.AddSimpleTool(40, wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP),
37 "Paste")
f0261a72
RD
38 EVT_TOOL(self, 40, self.OnToolClick)
39 EVT_TOOL_RCLICKED(self, 40, self.OnToolRClick)
40
41 tb.AddSeparator()
42
f0261a72
RD
43
44 tb.AddTool(60, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
1b55cabf 45 wxBitmap('bitmaps/tog2.bmp', wxBITMAP_TYPE_BMP),
c368d904 46 shortHelpString="Toggle with 2 bitmaps", isToggle=true)
f0261a72
RD
47 EVT_TOOL(self, 60, self.OnToolClick)
48 EVT_TOOL_RCLICKED(self, 60, self.OnToolRClick)
49 tb.Realize()
944930d5
RD
50
51 self.tb = tb
f6bcfd97 52 EVT_CLOSE(self, self.OnCloseWindow)
f0261a72
RD
53
54
55 def OnCloseWindow(self, event):
56 self.Destroy()
57
58 def OnToolClick(self, event):
59 self.log.WriteText("tool %s clicked\n" % event.GetId())
944930d5 60 if event.GetId() == 60:
b7e72427 61 print event.GetExtraLong(), event.Checked(), event.GetInt(), self.tb.GetToolState(60)
944930d5
RD
62 if event.GetExtraLong():
63 self.tb.SetTitle("")
64 else:
65 self.tb.SetTitle("Floating!")
f0261a72
RD
66
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!")
71
72#---------------------------------------------------------------------------
73
74def runTest(frame, nb, log):
75 win = TestFloatBar(frame, log)
76 frame.otherWin = win
77 win.Show(true)
78
79#---------------------------------------------------------------------------
80
81overview = """\
82wxFloatBar is a subclass of wxToolBar, implemented in Python, which can be detached from its frame.
83
944930d5 84Drag 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.
f0261a72 85
f0261a72
RD
86"""
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103