2 from wxPython
.wx
import *
4 #---------------------------------------------------------------------------
6 class TestToolBar(wxFrame
):
7 def __init__(self
, parent
, log
):
8 wxFrame
.__init
__(self
, parent
, -1, 'Test ToolBar',
9 wxPoint(0,0), wxSize(500, 300))
12 wxWindow(self
, -1).SetBackgroundColour(wxNamedColour("WHITE"))
14 tb
= self
.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER
) #|wxTB_FLAT)
15 #tb = wxToolBar(self, -1, wxDefaultPosition, wxDefaultSize,
16 # wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
19 self
.CreateStatusBar()
21 tb
.AddSimpleTool(10, wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP
),
22 "New", "Long help for 'New'")
23 EVT_TOOL(self
, 10, self
.OnToolClick
)
24 EVT_TOOL_RCLICKED(self
, 10, self
.OnToolRClick
)
26 tb
.AddSimpleTool(20, wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP
), "Open")
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
), "Copy")
32 EVT_TOOL(self
, 30, self
.OnToolClick
)
33 EVT_TOOL_RCLICKED(self
, 30, self
.OnToolRClick
)
35 tb
.AddSimpleTool(40, wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP
), "Paste")
36 EVT_TOOL(self
, 40, self
.OnToolClick
)
37 EVT_TOOL_RCLICKED(self
, 40, self
.OnToolRClick
)
41 tool
= tb
.AddTool(50, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP
),
42 shortHelpString
="Toggle this", isToggle
=true
)
43 EVT_TOOL(self
, 50, self
.OnToolClick
)
44 EVT_TOOL_RCLICKED(self
, 50, self
.OnToolRClick
)
46 tb
.AddTool(60, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP
),
47 wxBitmap('bitmaps/tog2.bmp', wxBITMAP_TYPE_BMP
),
48 shortHelpString
="Toggle with 2 bitmaps", isToggle
=true
)
49 EVT_TOOL(self
, 60, self
.OnToolClick
)
50 EVT_TOOL_RCLICKED(self
, 60, self
.OnToolRClick
)
55 tb
.AddControl(wxComboBox(tb
, cbID
, "", choices
=["", "This", "is a", "wxComboBox"],
56 size
=(150,-1), style
=wxCB_DROPDOWN
))
57 EVT_COMBOBOX(self
, cbID
, self
.OnCombo
)
60 EVT_CLOSE(self
, self
.OnCloseWindow
)
63 def OnCloseWindow(self
, event
):
66 def OnToolClick(self
, event
):
67 self
.log
.WriteText("tool %s clicked\n" % event
.GetId())
69 def OnToolRClick(self
, event
):
70 self
.log
.WriteText("tool %s right-clicked\n" % event
.GetId())
72 def OnCombo(self
, event
):
73 self
.log
.WriteText("combobox item selected: %s\n" % event
.GetString())
76 #---------------------------------------------------------------------------
78 def runTest(frame
, nb
, log
):
79 win
= TestToolBar(frame
, log
)
83 #---------------------------------------------------------------------------
101 The name wxToolBar is defined to be a synonym for one of the following classes:
103 wxToolBar95 The native Windows 95 toolbar. Used on Windows 95, NT 4 and above.
105 wxToolBarMSW A Windows implementation. Used on 16-bit Windows.
107 wxToolBarGTK The GTK toolbar.
109 wxToolBarSimple A simple implementation, with scrolling. Used on platforms with no native toolbar control, or where scrolling is required.
112 -----------------------
116 wxToolBar(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTB_HORIZONTAL | wxNO_BORDER, const wxString& name = wxPanelNameStr)
118 Constructs a toolbar.
123 parent = Pointer to a parent window.
125 id = Window identifier. If -1, will automatically create an identifier.
127 pos = Window position. wxDefaultPosition is (-1, -1) which indicates that wxWindows should generate a default position for the window. If using the wxWindow class directly, supply an actual position.
129 size = Window size. wxDefaultSize is (-1, -1) which indicates that wxWindows should generate a default size for the window.
131 style = Window style. See wxToolBar for details.