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