Commit e1d76c79dc374f18646065e7fa5fdde0608a44b9
1 parent
5f0b9064
Exists in
master
and in
68 other branches
ENH: Only binding in the submenu if it is running in Linux
Showing
1 changed file
with
6 additions
and
3 deletions
Show diff stats
invesalius/gui/widgets/slice_menu.py
| @@ -19,6 +19,7 @@ | @@ -19,6 +19,7 @@ | ||
| 19 | # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais | 19 | # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais |
| 20 | # detalhes. | 20 | # detalhes. |
| 21 | #-------------------------------------------------------------------------- | 21 | #-------------------------------------------------------------------------- |
| 22 | +import sys | ||
| 22 | 23 | ||
| 23 | import wx | 24 | import wx |
| 24 | import wx.lib.pubsub as ps | 25 | import wx.lib.pubsub as ps |
| @@ -36,8 +37,11 @@ class SliceMenu(wx.Menu): | @@ -36,8 +37,11 @@ class SliceMenu(wx.Menu): | ||
| 36 | submenu_wl.AppendItem(wl_item) | 37 | submenu_wl.AppendItem(wl_item) |
| 37 | self.ID_TO_TOOL_ITEM[new_id] = name | 38 | self.ID_TO_TOOL_ITEM[new_id] = name |
| 38 | self.AppendMenu(-1, "Window Width & Level", submenu_wl) | 39 | self.AppendMenu(-1, "Window Width & Level", submenu_wl) |
| 39 | - submenu_wl.Bind(wx.EVT_MENU, self.OnPopupWindowLevel) | ||
| 40 | - | 40 | + # It doesn't work in Linux |
| 41 | + self.Bind(wx.EVT_MENU, self.OnPopupWindowLevel) | ||
| 42 | + # In Linux the bind must be putted in the submenu | ||
| 43 | + if sys.platform == 'linux2': | ||
| 44 | + submenu_wl.Bind(wx.EVT_MENU, self.OnPopupWindowLevel) | ||
| 41 | 45 | ||
| 42 | def OnPopupWindowLevel(self, evt): | 46 | def OnPopupWindowLevel(self, evt): |
| 43 | key = self.ID_TO_TOOL_ITEM[evt.GetId()] | 47 | key = self.ID_TO_TOOL_ITEM[evt.GetId()] |
| @@ -46,4 +50,3 @@ class SliceMenu(wx.Menu): | @@ -46,4 +50,3 @@ class SliceMenu(wx.Menu): | ||
| 46 | (window, level)) | 50 | (window, level)) |
| 47 | ps.Publisher().sendMessage('Update slice viewer') | 51 | ps.Publisher().sendMessage('Update slice viewer') |
| 48 | evt.Skip() | 52 | evt.Skip() |
| 49 | - |