]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxToolBar.py
First draft of a cygwin script to create wxMSW distributions
[wxWidgets.git] / wxPython / demo / wxToolBar.py
CommitLineData
cf694132
RD
1
2from wxPython.wx import *
3
4#---------------------------------------------------------------------------
5
6class TestToolBar(wxFrame):
7 def __init__(self, parent, log):
8 wxFrame.__init__(self, parent, -1, 'Test ToolBar',
9 wxPoint(0,0), wxSize(500, 300))
10 self.log = log
11
12 wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
13
9b3d3bc4 14 tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER) #|wxTB_FLAT)
cf694132
RD
15 #tb = wxToolBar(self, -1, wxDefaultPosition, wxDefaultSize,
16 # wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
17 #self.SetToolBar(tb)
18
19 self.CreateStatusBar()
20
9b3d3bc4
RD
21 tb.AddSimpleTool(10, wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP),
22 "New", "Long help for 'New'")
cf694132
RD
23 EVT_TOOL(self, 10, self.OnToolClick)
24 EVT_TOOL_RCLICKED(self, 10, self.OnToolRClick)
25
9b3d3bc4 26 tb.AddSimpleTool(20, wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP), "Open")
cf694132
RD
27 EVT_TOOL(self, 20, self.OnToolClick)
28 EVT_TOOL_RCLICKED(self, 20, self.OnToolRClick)
29
30 tb.AddSeparator()
9b3d3bc4 31 tb.AddSimpleTool(30, wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP), "Copy")
cf694132
RD
32 EVT_TOOL(self, 30, self.OnToolClick)
33 EVT_TOOL_RCLICKED(self, 30, self.OnToolRClick)
34
9b3d3bc4 35 tb.AddSimpleTool(40, wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP), "Paste")
cf694132
RD
36 EVT_TOOL(self, 40, self.OnToolClick)
37 EVT_TOOL_RCLICKED(self, 40, self.OnToolRClick)
38
39 tb.AddSeparator()
40
9b3d3bc4
RD
41 tool = tb.AddTool(50, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
42 shortHelpString="Toggle this", toggle=true)
cf694132
RD
43 EVT_TOOL(self, 50, self.OnToolClick)
44 EVT_TOOL_RCLICKED(self, 50, self.OnToolRClick)
45
2f90df85
RD
46 tb.AddTool(60, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
47 wxBitmap('bitmaps/tog2.bmp', wxBITMAP_TYPE_BMP),
9b3d3bc4 48 shortHelpString="Toggle with 2 bitmaps", toggle=true)
cf694132
RD
49 EVT_TOOL(self, 60, self.OnToolClick)
50 EVT_TOOL_RCLICKED(self, 60, self.OnToolRClick)
51
9b3d3bc4
RD
52
53 tb.AddSeparator()
e02c03a4 54 tb.AddControl(wxComboBox(tb, -1, "", choices=["", "This", "is a", "wxComboBox"],
9b3d3bc4
RD
55 size=(150,-1), style=wxCB_DROPDOWN))
56
cf694132 57 tb.Realize()
f6bcfd97 58 EVT_CLOSE(self, self.OnCloseWindow)
cf694132
RD
59
60
61 def OnCloseWindow(self, event):
62 self.Destroy()
63
64 def OnToolClick(self, event):
65 self.log.WriteText("tool %s clicked\n" % event.GetId())
66
67 def OnToolRClick(self, event):
68 self.log.WriteText("tool %s right-clicked\n" % event.GetId())
69
70#---------------------------------------------------------------------------
71
72def runTest(frame, nb, log):
73 win = TestToolBar(frame, log)
74 frame.otherWin = win
75 win.Show(true)
76
77#---------------------------------------------------------------------------
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94overview = """\
95The name wxToolBar is defined to be a synonym for one of the following classes:
96
97wxToolBar95 The native Windows 95 toolbar. Used on Windows 95, NT 4 and above.
98
99wxToolBarMSW A Windows implementation. Used on 16-bit Windows.
100
101wxToolBarGTK The GTK toolbar.
102
103wxToolBarSimple A simple implementation, with scrolling. Used on platforms with no native toolbar control, or where scrolling is required.
104
105wxToolBar()
106-----------------------
107
108Default constructor.
109
110wxToolBar(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTB_HORIZONTAL | wxNO_BORDER, const wxString& name = wxPanelNameStr)
111
112Constructs a toolbar.
113
114Parameters
115-------------------
116
117parent = Pointer to a parent window.
118
119id = Window identifier. If -1, will automatically create an identifier.
120
121pos = 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.
122
123size = Window size. wxDefaultSize is (-1, -1) which indicates that wxWindows should generate a default size for the window.
124
125style = Window style. See wxToolBar for details.
126
127name = Window name.
128"""