]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxToolBar.py
corrected an superfluous initfloatingwindows call in carbon
[wxWidgets.git] / wxPython / demo / wxToolBar.py
1
2 from wxPython.wx import *
3
4 #---------------------------------------------------------------------------
5
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))
10 self.log = log
11 self.timer = None
12 EVT_CLOSE(self, self.OnCloseWindow)
13
14 wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
15
16 tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER|wxTB_FLAT)
17 #tb = wxToolBarSimple(self, -1, wxDefaultPosition, wxDefaultSize,
18 # wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
19 #self.SetToolBar(tb)
20
21 self.CreateStatusBar()
22
23 tb.AddSimpleTool(10, wxBitmap('bitmaps/new.bmp', wxBITMAP_TYPE_BMP),
24 "New", "Long help for 'New'")
25 EVT_TOOL(self, 10, self.OnToolClick)
26
27 tb.AddSimpleTool(20, wxBitmap('bitmaps/open.bmp', wxBITMAP_TYPE_BMP),
28 "Open", "Long help for 'Open'")
29 EVT_TOOL(self, 20, self.OnToolClick)
30
31 tb.AddSeparator()
32 tb.AddSimpleTool(30, wxBitmap('bitmaps/copy.bmp', wxBITMAP_TYPE_BMP),
33 "Copy", "Long help for 'Copy'")
34 EVT_TOOL(self, 30, self.OnToolClick)
35
36 tb.AddSimpleTool(40, wxBitmap('bitmaps/paste.bmp', wxBITMAP_TYPE_BMP),
37 "Paste", "Long help for 'Paste'")
38 EVT_TOOL(self, 40, self.OnToolClick)
39
40 tb.AddSeparator()
41
42 tool = tb.AddTool(50, wxBitmap('bitmaps/tog1.bmp', wxBITMAP_TYPE_BMP),
43 shortHelpString="Toggle this", isToggle=true)
44 EVT_TOOL(self, 50, self.OnToolClick)
45
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
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)
54
55 tb.AddSeparator()
56 cbID = wxNewId()
57 tb.AddControl(wxComboBox(tb, cbID, "", choices=["", "This", "is a", "wxComboBox"],
58 size=(150,-1), style=wxCB_DROPDOWN))
59 EVT_COMBOBOX(self, cbID, self.OnCombo)
60
61 tb.Realize()
62
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 def OnCombo(self, event):
71 self.log.WriteText("combobox item selected: %s\n" % event.GetString())
72
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): # called for the timer event handler
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()
92
93 #---------------------------------------------------------------------------
94
95 def 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
117 overview = """\
118
119 """