|
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 |
| - parent.AddTool(wx_ids[text], label=text, |
149 |
| - bitmap=bmp, |
150 |
| - bmpDisabled=wx.NullBitmap, |
151 |
| - shortHelpString=text, |
152 |
| - longHelpString=tooltip_text, |
153 |
| - kind=kind) |
| 152 | + add_tool = parent.AddTool |
| 153 | + else: |
| 154 | + add_tool = parent.DoAddTool |
| 155 | + |
| 156 | + if not is_phoenix or LooseVersion(wx.VERSION_STRING) >= "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) |
154 | 166 | else:
|
155 |
| - if text in ['Pan', 'Zoom']: |
156 |
| - parent.AddCheckTool( |
157 |
| - wx_ids[text], |
158 |
| - bmp, |
159 |
| - shortHelp=text, |
160 |
| - longHelp=tooltip_text) |
161 |
| - else: |
162 |
| - 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) |
0 commit comments