]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxToolBar.py
added missing string definition
[wxWidgets.git] / wxPython / demo / wxToolBar.py
CommitLineData
cf694132
RD
1
2from wxPython.wx import *
3
96bfd053
RD
4import images
5
cf694132
RD
6#---------------------------------------------------------------------------
7
8class TestToolBar(wxFrame):
9 def __init__(self, parent, log):
10 wxFrame.__init__(self, parent, -1, 'Test ToolBar',
11 wxPoint(0,0), wxSize(500, 300))
12 self.log = log
185d7c3e
RD
13 self.timer = None
14 EVT_CLOSE(self, self.OnCloseWindow)
cf694132
RD
15
16 wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
17
1b62f00d 18 tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER|wxTB_FLAT)
d56cebe7 19 # wxTB_VERTICAL
185d7c3e 20 #tb = wxToolBarSimple(self, -1, wxDefaultPosition, wxDefaultSize,
cf694132
RD
21 # wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
22 #self.SetToolBar(tb)
23
24 self.CreateStatusBar()
25
96bfd053 26 tb.AddSimpleTool(10, images.getNewBitmap(), "New", "Long help for 'New'")
cf694132 27 EVT_TOOL(self, 10, self.OnToolClick)
96bfd053 28 EVT_TOOL_RCLICKED(self, 10, self.OnToolRClick)
cf694132 29
a92edd31 30 tb.AddSimpleTool(20, images.getOpenBitmap(), "Open", "Long help for 'Open'")
cf694132 31 EVT_TOOL(self, 20, self.OnToolClick)
96bfd053 32 EVT_TOOL_RCLICKED(self, 20, self.OnToolRClick)
cf694132
RD
33
34 tb.AddSeparator()
a92edd31 35 tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy", "Long help for 'Copy'")
cf694132 36 EVT_TOOL(self, 30, self.OnToolClick)
96bfd053 37 EVT_TOOL_RCLICKED(self, 30, self.OnToolRClick)
cf694132 38
a92edd31 39 tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste", "Long help for 'Paste'")
cf694132 40 EVT_TOOL(self, 40, self.OnToolClick)
96bfd053 41 EVT_TOOL_RCLICKED(self, 40, self.OnToolRClick)
cf694132
RD
42
43 tb.AddSeparator()
44
96bfd053 45 tool = tb.AddTool(50, images.getTog1Bitmap(),
c368d904 46 shortHelpString="Toggle this", isToggle=true)
cf694132 47 EVT_TOOL(self, 50, self.OnToolClick)
cf694132 48
96bfd053 49 tb.AddTool(60, images.getTog1Bitmap(), images.getTog2Bitmap(),
c368d904 50 shortHelpString="Toggle with 2 bitmaps", isToggle=true)
cf694132 51 EVT_TOOL(self, 60, self.OnToolClick)
cf694132 52
185d7c3e
RD
53 EVT_TOOL_ENTER(self, -1, self.OnToolEnter)
54 EVT_TOOL_RCLICKED(self, -1, self.OnToolRClick) # Match all
55 EVT_TIMER(self, -1, self.OnClearSB)
9b3d3bc4
RD
56
57 tb.AddSeparator()
c368d904
RD
58 cbID = wxNewId()
59 tb.AddControl(wxComboBox(tb, cbID, "", choices=["", "This", "is a", "wxComboBox"],
9b3d3bc4 60 size=(150,-1), style=wxCB_DROPDOWN))
c368d904 61 EVT_COMBOBOX(self, cbID, self.OnCombo)
9b3d3bc4 62
cf694132
RD
63 tb.Realize()
64
65
cf694132
RD
66 def OnToolClick(self, event):
67 self.log.WriteText("tool %s clicked\n" % event.GetId())
68
69 def OnToolRClick(self, event):
70 self.log.WriteText("tool %s right-clicked\n" % event.GetId())
71
c368d904
RD
72 def OnCombo(self, event):
73 self.log.WriteText("combobox item selected: %s\n" % event.GetString())
74
185d7c3e
RD
75 def OnToolEnter(self, event):
76 self.log.WriteText('OnToolEnter: %s, %s\n' % (event.GetId(), event.GetInt()))
77 if self.timer is None:
78 self.timer = wxTimer(self)
a92edd31
RD
79 if self.timer.IsRunning():
80 self.timer.Stop()
185d7c3e
RD
81 self.timer.Start(2000)
82 event.Skip()
83
84
de20db99 85 def OnClearSB(self, event): # called for the timer event handler
185d7c3e
RD
86 self.SetStatusText("")
87 self.timer.Stop()
88 self.timer = None
89
90
91 def OnCloseWindow(self, event):
92 if self.timer is not None:
93 self.timer.Stop()
94 self.timer = None
95 self.Destroy()
c368d904 96
cf694132
RD
97#---------------------------------------------------------------------------
98
99def runTest(frame, nb, log):
100 win = TestToolBar(frame, log)
101 frame.otherWin = win
102 win.Show(true)
103
104#---------------------------------------------------------------------------
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121overview = """\
cf694132 122
cf694132 123"""