]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxToolBar.py
New typemaps for wxString when compiling for Python 2.0 and beyond
[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
185d7c3e
RD
11 self.timer = None
12 EVT_CLOSE(self, self.OnCloseWindow)
cf694132
RD
13
14 wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
15
9b3d3bc4 16 tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER) #|wxTB_FLAT)
185d7c3e 17 #tb = wxToolBarSimple(self, -1, wxDefaultPosition, wxDefaultSize,
cf694132
RD
18 # wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
19 #self.SetToolBar(tb)
20
21 self.CreateStatusBar()
22
9b3d3bc4
RD
23 tb.AddSimpleTool(10, wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP),
24 "New", "Long help for 'New'")
cf694132 25 EVT_TOOL(self, 10, self.OnToolClick)
cf694132 26
185d7c3e
RD
27 tb.AddSimpleTool(20, wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP),
28 "Open", "Long help for 'Open'")
cf694132 29 EVT_TOOL(self, 20, self.OnToolClick)
cf694132
RD
30
31 tb.AddSeparator()
185d7c3e
RD
32 tb.AddSimpleTool(30, wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP),
33 "Copy", "Long help for 'Copy'")
cf694132 34 EVT_TOOL(self, 30, self.OnToolClick)
cf694132 35
185d7c3e
RD
36 tb.AddSimpleTool(40, wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP),
37 "Paste", "Long help for 'Paste'")
cf694132 38 EVT_TOOL(self, 40, self.OnToolClick)
cf694132
RD
39
40 tb.AddSeparator()
41
9b3d3bc4 42 tool = tb.AddTool(50, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
c368d904 43 shortHelpString="Toggle this", isToggle=true)
cf694132 44 EVT_TOOL(self, 50, self.OnToolClick)
cf694132 45
2f90df85
RD
46 tb.AddTool(60, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
47 wxBitmap('bitmaps/tog2.bmp', wxBITMAP_TYPE_BMP),
c368d904 48 shortHelpString="Toggle with 2 bitmaps", isToggle=true)
cf694132 49 EVT_TOOL(self, 60, self.OnToolClick)
cf694132 50
185d7c3e
RD
51 EVT_TOOL_ENTER(self, -1, self.OnToolEnter)
52 EVT_TOOL_RCLICKED(self, -1, self.OnToolRClick) # Match all
53 EVT_TIMER(self, -1, self.OnClearSB)
9b3d3bc4
RD
54
55 tb.AddSeparator()
c368d904
RD
56 cbID = wxNewId()
57 tb.AddControl(wxComboBox(tb, cbID, "", choices=["", "This", "is a", "wxComboBox"],
9b3d3bc4 58 size=(150,-1), style=wxCB_DROPDOWN))
c368d904 59 EVT_COMBOBOX(self, cbID, self.OnCombo)
9b3d3bc4 60
cf694132
RD
61 tb.Realize()
62
63
cf694132
RD
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
c368d904
RD
70 def OnCombo(self, event):
71 self.log.WriteText("combobox item selected: %s\n" % event.GetString())
72
185d7c3e
RD
73 def OnToolEnter(self, event):
74 self.log.WriteText('OnToolEnter: %s, %s\n' % (event.GetId(), event.GetInt()))
75 if self.timer is None:
76 self.timer = wxTimer(self)
77 self.timer.Start(2000)
78 event.Skip()
79
80
81 def OnClearSB(self, event):
82 self.SetStatusText("")
83 self.timer.Stop()
84 self.timer = None
85
86
87 def OnCloseWindow(self, event):
88 if self.timer is not None:
89 self.timer.Stop()
90 self.timer = None
91 self.Destroy()
c368d904 92
cf694132
RD
93#---------------------------------------------------------------------------
94
95def runTest(frame, nb, log):
96 win = TestToolBar(frame, log)
97 frame.otherWin = win
98 win.Show(true)
99
100#---------------------------------------------------------------------------
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117overview = """\
cf694132 118
cf694132 119"""