|
139 | 139 | StockCursor = wx.StockCursor
|
140 | 140 |
|
141 | 141 |
|
| 142 | +# wxPython Classic's DoAddTool has become AddTool in Phoenix. Otherwise |
| 143 | +# they are the same, except for early betas and prerelease builds of |
| 144 | +# Phoenix. This function provides a shim that does the RightThing based on |
| 145 | +# which wxPython is in use. |
142 | 146 | def _AddTool(parent, wx_ids, text, bmp, tooltip_text):
|
| 147 | + if text in ['Pan', 'Zoom']: |
| 148 | + kind = wx.ITEM_CHECK |
| 149 | + else: |
| 150 | + kind = wx.ITEM_NORMAL |
143 | 151 | if is_phoenix:
|
144 |
| - if text in ['Pan', 'Zoom']: |
145 |
| - kind = wx.ITEM_CHECK |
146 |
| - else: |
147 |
| - kind = wx.ITEM_NORMAL |
148 |
| - |
149 |
| - if LooseVersion(wx.VERSION_STRING) >= LooseVersion("4.0.0b2"): |
150 |
| - kwargs = dict(label=text, |
151 |
| - bitmap=bmp, |
152 |
| - bmpDisabled=wx.NullBitmap, |
153 |
| - shortHelp=text, |
154 |
| - longHelp=tooltip_text, |
155 |
| - kind=kind) |
156 |
| - else: |
157 |
| - kwargs = dict(label=text, |
158 |
| - bitmap=bmp, |
159 |
| - bmpDisabled=wx.NullBitmap, |
160 |
| - shortHelpString=text, |
161 |
| - longHelpString=tooltip_text, |
162 |
| - kind=kind) |
163 |
| - |
164 |
| - parent.AddTool(wx_ids[text], **kwargs) |
| 152 | + add_tool = parent.AddTool |
| 153 | + else: |
| 154 | + add_tool = parent.DoAddTool |
| 155 | + |
| 156 | + if not is_phoenix or LooseVersion(wx.VERSION_STRING) >= LooseVersion("4.0.0b2"): |
| 157 | + # NOTE: when support for Phoenix prior to 4.0.0b2 is dropped then |
| 158 | + # all that is needed is this clause, and the if and else clause can |
| 159 | + # be removed. |
| 160 | + kwargs = dict(label=text, |
| 161 | + bitmap=bmp, |
| 162 | + bmpDisabled=wx.NullBitmap, |
| 163 | + shortHelp=text, |
| 164 | + longHelp=tooltip_text, |
| 165 | + kind=kind) |
165 | 166 | else:
|
166 |
| - if text in ['Pan', 'Zoom']: |
167 |
| - parent.AddCheckTool( |
168 |
| - wx_ids[text], |
169 |
| - bmp, |
170 |
| - shortHelp=text, |
171 |
| - longHelp=tooltip_text) |
172 |
| - else: |
173 |
| - parent.AddSimpleTool(wx_ids[text], bmp, text, tooltip_text) |
| 167 | + kwargs = dict(label=text, |
| 168 | + bitmap=bmp, |
| 169 | + bmpDisabled=wx.NullBitmap, |
| 170 | + shortHelpString=text, |
| 171 | + longHelpString=tooltip_text, |
| 172 | + kind=kind) |
| 173 | + |
| 174 | + return add_tool(wx_ids[text], **kwargs) |
| 175 | + |
0 commit comments