Commit eac24f4f8f25444c3f8036b7b53e54ebee8c29b2

Authored by Thiago Franco de Moraes
Committed by GitHub
1 parent 9eb75dca
Exists in master

Remove WX deprecated code, improve gradient (#182)

* using calllater instead of futurecall

* Using Append instead of AppendMenu in slice_menu

* Using Append instead of AppendItem in slice_menu

* Using Append instead of AppendItem in rest of source code

* Using Append instead of AppendMenu in rest of source code

* Using Bitmap instead of BitmapFromImage

* GetVirtualSizeTuple -> GetVirtualSize

* SetToolTipString -> SetToolTip

* ImageFromStream -> Image

* using self.bind to undo and redo tool

* wx.EmptyBitmapRGBA to wx.Bitmap

* EmptyImage -> Image

* InsertStringItem -> InsertItem

* SetStringItem -> SetItem

* wx.StockCursor to wx.Cursor

* GetSizeTuple -> GetSize

* Less time in dicom loading from cmdline

* Created an alternative class to SpinCtrl

* Using InvSpinCtrl in task_slice

* implementing float spinctrl

* Added InvFloatSpinCtrl

* Using InvSpinCtrl in task_surface

* Using InvSpinCtrl in regiongrowing dialog

* Using InvSpinCtrl in watershed config dialgo

* Using InvSpinCtrl in contextawaresmoothing config dialog

* Using InvSpinCtrl in fillholes auto config dialog

* Using InvSpinCtrl in the resizeimage dialog

* Using InvSpinCtrl in the bitmap spacing dialog

* removed all wx.predialog

* Using InvSpinCtrl gradient ctrl

* align to the right by default

* Added Spinbutton at inv_spinctrl

* formatation

* Using other way to calc invspinctrl size

* better size of spin button

* better size of spin button

* improvements

* better gradient code format

* Improvements in gradient ctrl

* Using gradientctrl instead of gradientslider in new mask

* better invspinctrl size to mac

* moved invspinctrl to widgets

* better size to mac
@@ -247,9 +247,9 @@ class Inv3SplashScreen(SplashScreen): @@ -247,9 +247,9 @@ class Inv3SplashScreen(SplashScreen):
247 self.main = Frame(None) 247 self.main = Frame(None)
248 self.control = Controller(self.main) 248 self.control = Controller(self.main)
249 249
250 - self.fc = wx.FutureCall(1, self.ShowMain) 250 + self.fc = wx.CallLater(200, self.ShowMain)
251 options, args = parse_comand_line() 251 options, args = parse_comand_line()
252 - wx.FutureCall(1, use_cmd_optargs, options, args) 252 + wx.CallLater(1, use_cmd_optargs, options, args)
253 253
254 # Check for updates 254 # Check for updates
255 from threading import Thread 255 from threading import Thread
invesalius/data/styles.py
@@ -467,9 +467,9 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle): @@ -467,9 +467,9 @@ class LinearMeasureInteractorStyle(DefaultInteractorStyle):
467 else: 467 else:
468 mx, my = self.viewer.interactor.GetEventPosition() 468 mx, my = self.viewer.interactor.GetEventPosition()
469 if self._verify_clicked_display(mx, my): 469 if self._verify_clicked_display(mx, my):
470 - self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_HAND)) 470 + self.viewer.interactor.SetCursor(wx.Cursor(wx.CURSOR_HAND))
471 else: 471 else:
472 - self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) 472 + self.viewer.interactor.SetCursor(wx.Cursor(wx.CURSOR_DEFAULT))
473 473
474 def OnLeaveMeasureInteractor(self, obj, evt): 474 def OnLeaveMeasureInteractor(self, obj, evt):
475 if self.creating or self.selected: 475 if self.creating or self.selected:
@@ -922,7 +922,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): @@ -922,7 +922,7 @@ class EditorInteractorStyle(DefaultInteractorStyle):
922 w_x, w_y, w_z = self.viewer.get_coordinate_cursor(x, y, self.picker) 922 w_x, w_y, w_z = self.viewer.get_coordinate_cursor(x, y, self.picker)
923 self.viewer.slice_data.cursor.SetPosition((w_x, w_y, w_z)) 923 self.viewer.slice_data.cursor.SetPosition((w_x, w_y, w_z))
924 924
925 - self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) 925 + self.viewer.interactor.SetCursor(wx.Cursor(wx.CURSOR_BLANK))
926 self.viewer.interactor.Render() 926 self.viewer.interactor.Render()
927 927
928 def CleanUp(self): 928 def CleanUp(self):
@@ -931,7 +931,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): @@ -931,7 +931,7 @@ class EditorInteractorStyle(DefaultInteractorStyle):
931 Publisher.unsubscribe(self.set_boperation, 'Set edition operation') 931 Publisher.unsubscribe(self.set_boperation, 'Set edition operation')
932 932
933 self.viewer.slice_data.cursor.Show(0) 933 self.viewer.slice_data.cursor.Show(0)
934 - self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) 934 + self.viewer.interactor.SetCursor(wx.Cursor(wx.CURSOR_DEFAULT))
935 self.viewer.interactor.Render() 935 self.viewer.interactor.Render()
936 936
937 def set_bsize(self, size): 937 def set_bsize(self, size):
@@ -967,12 +967,12 @@ class EditorInteractorStyle(DefaultInteractorStyle): @@ -967,12 +967,12 @@ class EditorInteractorStyle(DefaultInteractorStyle):
967 if (self.viewer.slice_.buffer_slices[self.orientation].mask is None): 967 if (self.viewer.slice_.buffer_slices[self.orientation].mask is None):
968 return 968 return
969 self.viewer.slice_data.cursor.Show() 969 self.viewer.slice_data.cursor.Show()
970 - self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) 970 + self.viewer.interactor.SetCursor(wx.Cursor(wx.CURSOR_BLANK))
971 self.viewer.interactor.Render() 971 self.viewer.interactor.Render()
972 972
973 def OnLeaveInteractor(self, obj, evt): 973 def OnLeaveInteractor(self, obj, evt):
974 self.viewer.slice_data.cursor.Show(0) 974 self.viewer.slice_data.cursor.Show(0)
975 - self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) 975 + self.viewer.interactor.SetCursor(wx.Cursor(wx.CURSOR_DEFAULT))
976 self.viewer.interactor.Render() 976 self.viewer.interactor.Render()
977 977
978 def OnBrushClick(self, obj, evt): 978 def OnBrushClick(self, obj, evt):
@@ -1230,7 +1230,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): @@ -1230,7 +1230,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle):
1230 w_x, w_y, w_z = self.viewer.get_coordinate_cursor(x, y, self.picker) 1230 w_x, w_y, w_z = self.viewer.get_coordinate_cursor(x, y, self.picker)
1231 self.viewer.slice_data.cursor.SetPosition((w_x, w_y, w_z)) 1231 self.viewer.slice_data.cursor.SetPosition((w_x, w_y, w_z))
1232 1232
1233 - self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) 1233 + self.viewer.interactor.SetCursor(wx.Cursor(wx.CURSOR_BLANK))
1234 self.viewer.interactor.Render() 1234 self.viewer.interactor.Render()
1235 1235
1236 def CleanUp(self): 1236 def CleanUp(self):
@@ -1243,7 +1243,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): @@ -1243,7 +1243,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle):
1243 self.viewer.OnScrollBar() 1243 self.viewer.OnScrollBar()
1244 1244
1245 self.viewer.slice_data.cursor.Show(0) 1245 self.viewer.slice_data.cursor.Show(0)
1246 - self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) 1246 + self.viewer.interactor.SetCursor(wx.Cursor(wx.CURSOR_DEFAULT))
1247 self.viewer.interactor.Render() 1247 self.viewer.interactor.Render()
1248 1248
1249 def _create_mask(self): 1249 def _create_mask(self):
@@ -1290,12 +1290,12 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): @@ -1290,12 +1290,12 @@ class WaterShedInteractorStyle(DefaultInteractorStyle):
1290 if (self.viewer.slice_.buffer_slices[self.orientation].mask is None): 1290 if (self.viewer.slice_.buffer_slices[self.orientation].mask is None):
1291 return 1291 return
1292 self.viewer.slice_data.cursor.Show() 1292 self.viewer.slice_data.cursor.Show()
1293 - self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_BLANK)) 1293 + self.viewer.interactor.SetCursor(wx.Cursor(wx.CURSOR_BLANK))
1294 self.viewer.interactor.Render() 1294 self.viewer.interactor.Render()
1295 1295
1296 def OnLeaveInteractor(self, obj, evt): 1296 def OnLeaveInteractor(self, obj, evt):
1297 self.viewer.slice_data.cursor.Show(0) 1297 self.viewer.slice_data.cursor.Show(0)
1298 - self.viewer.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) 1298 + self.viewer.interactor.SetCursor(wx.Cursor(wx.CURSOR_DEFAULT))
1299 self.viewer.interactor.Render() 1299 self.viewer.interactor.Render()
1300 1300
1301 def WOnScrollBackward(self, obj, evt): 1301 def WOnScrollBackward(self, obj, evt):
@@ -1757,10 +1757,10 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle): @@ -1757,10 +1757,10 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle):
1757 dist_center = ((mx - cx)**2 + (my - cy)**2)**0.5 1757 dist_center = ((mx - cx)**2 + (my - cy)**2)**0.5
1758 if dist_center <= 15: 1758 if dist_center <= 15:
1759 self._over_center = True 1759 self._over_center = True
1760 - cursor = wx.StockCursor(wx.CURSOR_SIZENESW) 1760 + cursor = wx.Cursor(wx.CURSOR_SIZENESW)
1761 else: 1761 else:
1762 self._over_center = False 1762 self._over_center = False
1763 - cursor = wx.StockCursor(wx.CURSOR_DEFAULT) 1763 + cursor = wx.Cursor(wx.CURSOR_DEFAULT)
1764 1764
1765 self.viewer.interactor.SetCursor(cursor) 1765 self.viewer.interactor.SetCursor(cursor)
1766 1766
invesalius/data/viewer_slice.py
@@ -49,6 +49,7 @@ import invesalius.session as ses @@ -49,6 +49,7 @@ import invesalius.session as ses
49 import invesalius.data.converters as converters 49 import invesalius.data.converters as converters
50 import invesalius.data.measures as measures 50 import invesalius.data.measures as measures
51 51
  52 +from invesalius.gui.widgets.inv_spinctrl import InvSpinCtrl, InvFloatSpinCtrl
52 from invesalius.gui.widgets.canvas_renderer import CanvasRendererCTX 53 from invesalius.gui.widgets.canvas_renderer import CanvasRendererCTX
53 54
54 if sys.platform == 'win32': 55 if sys.platform == 'win32':
@@ -73,25 +74,22 @@ ORIENTATIONS = { @@ -73,25 +74,22 @@ ORIENTATIONS = {
73 class ContourMIPConfig(wx.Panel): 74 class ContourMIPConfig(wx.Panel):
74 def __init__(self, prnt, orientation): 75 def __init__(self, prnt, orientation):
75 wx.Panel.__init__(self, prnt) 76 wx.Panel.__init__(self, prnt)
76 - self.mip_size_spin = wx.SpinCtrl(self, -1, min=1, max=240,  
77 - initial=const.PROJECTION_MIP_SIZE)  
78 - self.mip_size_spin.SetValue(const.PROJECTION_MIP_SIZE) 77 + self.mip_size_spin = InvSpinCtrl(self, -1, value=const.PROJECTION_MIP_SIZE, min_value=1, max_value=240)
79 self.mip_size_spin.SetToolTip(wx.ToolTip(_("Number of slices used to compound the visualization."))) 78 self.mip_size_spin.SetToolTip(wx.ToolTip(_("Number of slices used to compound the visualization.")))
80 - w, h = self.mip_size_spin.GetTextExtent('M')  
81 - self.mip_size_spin.SetMinSize((5 * w + 10, -1))  
82 - self.mip_size_spin.SetMaxSize((5 * w + 10, -1)) 79 + self.mip_size_spin.CalcSizeFromTextSize('MMM')
83 80
84 - self.border_spin = FS.FloatSpin(self, -1, min_val=0, max_val=10, 81 + self.border_spin = InvFloatSpinCtrl(self, -1, min_value=0, max_value=10,
85 increment=0.1, 82 increment=0.1,
86 value=const.PROJECTION_BORDER_SIZE, 83 value=const.PROJECTION_BORDER_SIZE,
87 - digits=1, agwStyle=FS.FS_LEFT) 84 + digits=1)
88 self.border_spin.SetToolTip(wx.ToolTip(_("Controls the sharpness of the" 85 self.border_spin.SetToolTip(wx.ToolTip(_("Controls the sharpness of the"
89 " contour. The greater the" 86 " contour. The greater the"
90 " value, the sharper the" 87 " value, the sharper the"
91 " contour."))) 88 " contour.")))
92 - w, h = self.border_spin.GetTextExtent('M')  
93 - self.border_spin.SetMinSize((5 * w + 10, -1))  
94 - self.border_spin.SetMaxSize((5 * w + 10, -1)) 89 + self.border_spin.CalcSizeFromTextSize()
  90 + # w, h = self.border_spin.GetTextExtent('M')
  91 + # self.border_spin.SetMinSize((5 * w + 10, -1))
  92 + # self.border_spin.SetMaxSize((5 * w + 10, -1))
95 93
96 self.inverted = wx.CheckBox(self, -1, _("Inverted order")) 94 self.inverted = wx.CheckBox(self, -1, _("Inverted order"))
97 self.inverted.SetToolTip(wx.ToolTip(_("If checked, the slices are" 95 self.inverted.SetToolTip(wx.ToolTip(_("If checked, the slices are"
@@ -105,7 +103,7 @@ class ContourMIPConfig(wx.Panel): @@ -105,7 +103,7 @@ class ContourMIPConfig(wx.Panel):
105 103
106 sizer = wx.BoxSizer(wx.HORIZONTAL) 104 sizer = wx.BoxSizer(wx.HORIZONTAL)
107 sizer.Add(txt_mip_size, 0, wx.EXPAND | wx.ALL, 2) 105 sizer.Add(txt_mip_size, 0, wx.EXPAND | wx.ALL, 2)
108 - sizer.Add(self.mip_size_spin, 0, wx.EXPAND) 106 + sizer.Add(self.mip_size_spin, 0)
109 try: 107 try:
110 sizer.Add(10, 0) 108 sizer.Add(10, 0)
111 except TypeError: 109 except TypeError:
@@ -883,19 +881,19 @@ class Viewer(wx.Panel): @@ -883,19 +881,19 @@ class Viewer(wx.Panel):
883 self.Refresh() 881 self.Refresh()
884 882
885 def SetDefaultCursor(self): 883 def SetDefaultCursor(self):
886 - self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT)) 884 + self.interactor.SetCursor(wx.Cursor(wx.CURSOR_DEFAULT))
887 885
888 def SetSizeNSCursor(self): 886 def SetSizeNSCursor(self):
889 - self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZENS)) 887 + self.interactor.SetCursor(wx.Cursor(wx.CURSOR_SIZENS))
890 888
891 def SetSizeWECursor(self): 889 def SetSizeWECursor(self):
892 - self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZEWE)) 890 + self.interactor.SetCursor(wx.Cursor(wx.CURSOR_SIZEWE))
893 891
894 def SetSizeNWSECursor(self): 892 def SetSizeNWSECursor(self):
895 if sys.platform.startswith('linux'): 893 if sys.platform.startswith('linux'):
896 - self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZENWSE)) 894 + self.interactor.SetCursor(wx.Cursor(wx.CURSOR_SIZENWSE))
897 else: 895 else:
898 - self.interactor.SetCursor(wx.StockCursor(wx.CURSOR_SIZING)) 896 + self.interactor.SetCursor(wx.Cursor(wx.CURSOR_SIZING))
899 897
900 def SetFocus(self): 898 def SetFocus(self):
901 Publisher.sendMessage('Set viewer orientation focus', 899 Publisher.sendMessage('Set viewer orientation focus',
invesalius/gui/bitmap_preview_panel.py
@@ -115,7 +115,7 @@ class DicomPaintPanel(wx.Panel): @@ -115,7 +115,7 @@ class DicomPaintPanel(wx.Panel):
115 self.Bind(wx.EVT_SIZE, self.OnSize) 115 self.Bind(wx.EVT_SIZE, self.OnSize)
116 116
117 def _build_bitmap(self, image): 117 def _build_bitmap(self, image):
118 - bmp = wx.BitmapFromImage(image) 118 + bmp = wx.Bitmap(image)
119 return bmp 119 return bmp
120 120
121 def _image_resize(self, image): 121 def _image_resize(self, image):
invesalius/gui/data_notebook.py
@@ -168,20 +168,20 @@ class MeasureButtonControlPanel(wx.Panel): @@ -168,20 +168,20 @@ class MeasureButtonControlPanel(wx.Panel):
168 BMP_NEW, 168 BMP_NEW,
169 style=button_style, 169 style=button_style,
170 size = wx.Size(24, 20)) 170 size = wx.Size(24, 20))
171 - button_new.SetToolTipString(_("Create a new measure")) 171 + button_new.SetToolTip(_("Create a new measure"))
172 self.button_new = button_new 172 self.button_new = button_new
173 173
174 button_remove = pbtn.PlateButton(self, BTN_REMOVE, "", 174 button_remove = pbtn.PlateButton(self, BTN_REMOVE, "",
175 BMP_REMOVE, 175 BMP_REMOVE,
176 style=button_style, 176 style=button_style,
177 size = wx.Size(24, 20)) 177 size = wx.Size(24, 20))
178 - button_remove.SetToolTipString(_("Remove measure")) 178 + button_remove.SetToolTip(_("Remove measure"))
179 179
180 button_duplicate = pbtn.PlateButton(self, BTN_DUPLICATE, "", 180 button_duplicate = pbtn.PlateButton(self, BTN_DUPLICATE, "",
181 BMP_DUPLICATE, 181 BMP_DUPLICATE,
182 style=button_style, 182 style=button_style,
183 size = wx.Size(24, 20)) 183 size = wx.Size(24, 20))
184 - button_duplicate.SetToolTipString(_("Duplicate measure")) 184 + button_duplicate.SetToolTip(_("Duplicate measure"))
185 button_duplicate.Disable() 185 button_duplicate.Disable()
186 186
187 # Add all controls to gui 187 # Add all controls to gui
@@ -195,10 +195,10 @@ class MeasureButtonControlPanel(wx.Panel): @@ -195,10 +195,10 @@ class MeasureButtonControlPanel(wx.Panel):
195 menu = wx.Menu() 195 menu = wx.Menu()
196 item = wx.MenuItem(menu, const.MEASURE_LINEAR, 196 item = wx.MenuItem(menu, const.MEASURE_LINEAR,
197 _("Measure distance")) 197 _("Measure distance"))
198 - menu.AppendItem(item) 198 + menu.Append(item)
199 item = wx.MenuItem(menu, const.MEASURE_ANGULAR, 199 item = wx.MenuItem(menu, const.MEASURE_ANGULAR,
200 _("Measure angle")) 200 _("Measure angle"))
201 - menu.AppendItem(item) 201 + menu.Append(item)
202 menu.Bind(wx.EVT_MENU, self.OnMenu) 202 menu.Bind(wx.EVT_MENU, self.OnMenu)
203 self.menu = menu 203 self.menu = menu
204 204
@@ -286,19 +286,19 @@ class ButtonControlPanel(wx.Panel): @@ -286,19 +286,19 @@ class ButtonControlPanel(wx.Panel):
286 BMP_NEW, 286 BMP_NEW,
287 style=button_style, 287 style=button_style,
288 size = wx.Size(24, 20)) 288 size = wx.Size(24, 20))
289 - button_new.SetToolTipString(_("Create a new mask")) 289 + button_new.SetToolTip(_("Create a new mask"))
290 290
291 button_remove = pbtn.PlateButton(self, BTN_REMOVE, "", 291 button_remove = pbtn.PlateButton(self, BTN_REMOVE, "",
292 BMP_REMOVE, 292 BMP_REMOVE,
293 style=button_style, 293 style=button_style,
294 size = wx.Size(24, 20)) 294 size = wx.Size(24, 20))
295 - button_remove.SetToolTipString(_("Remove mask")) 295 + button_remove.SetToolTip(_("Remove mask"))
296 296
297 button_duplicate = pbtn.PlateButton(self, BTN_DUPLICATE, "", 297 button_duplicate = pbtn.PlateButton(self, BTN_DUPLICATE, "",
298 BMP_DUPLICATE, 298 BMP_DUPLICATE,
299 style=button_style, 299 style=button_style,
300 size = wx.Size(24, 20)) 300 size = wx.Size(24, 20))
301 - button_duplicate.SetToolTipString(_("Duplicate mask")) 301 + button_duplicate.SetToolTip(_("Duplicate mask"))
302 302
303 # Add all controls to gui 303 # Add all controls to gui
304 sizer = wx.BoxSizer(wx.HORIZONTAL) 304 sizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -474,13 +474,13 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckListCt @@ -474,13 +474,13 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckListCt
474 self.imagelist = wx.ImageList(16, 16) 474 self.imagelist = wx.ImageList(16, 16)
475 475
476 image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg")) 476 image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg"))
477 - bitmap = wx.BitmapFromImage(image.Scale(16, 16)) 477 + bitmap = wx.Bitmap(image.Scale(16, 16))
478 bitmap.SetWidth(16) 478 bitmap.SetWidth(16)
479 bitmap.SetHeight(16) 479 bitmap.SetHeight(16)
480 img_null = self.imagelist.Add(bitmap) 480 img_null = self.imagelist.Add(bitmap)
481 481
482 image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg")) 482 image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg"))
483 - bitmap = wx.BitmapFromImage(image.Scale(16, 16)) 483 + bitmap = wx.Bitmap(image.Scale(16, 16))
484 bitmap.SetWidth(16) 484 bitmap.SetWidth(16)
485 bitmap.SetHeight(16) 485 bitmap.SetHeight(16)
486 img_check = self.imagelist.Add(bitmap) 486 img_check = self.imagelist.Add(bitmap)
@@ -526,20 +526,20 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckListCt @@ -526,20 +526,20 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckListCt
526 for i in colour] 526 for i in colour]
527 new_image.putpixel((x,y), tuple(pixel_colour)) 527 new_image.putpixel((x,y), tuple(pixel_colour))
528 528
529 - wx_image = wx.EmptyImage(new_image.size[0],  
530 - new_image.size[1]) 529 + wx_image = wx.Image(new_image.size[0],
  530 + new_image.size[1])
531 try: 531 try:
532 wx_image.SetData(new_image.tostring()) 532 wx_image.SetData(new_image.tostring())
533 except Exception: 533 except Exception:
534 wx_image.SetData(new_image.tobytes()) 534 wx_image.SetData(new_image.tobytes())
535 - return wx.BitmapFromImage(wx_image.Scale(16, 16)) 535 + return wx.Bitmap(wx_image.Scale(16, 16))
536 536
537 def InsertNewItem(self, index=0, label=_("Mask"), threshold="(1000, 4500)", 537 def InsertNewItem(self, index=0, label=_("Mask"), threshold="(1000, 4500)",
538 colour=None): 538 colour=None):
539 - self.InsertStringItem(index, "")  
540 - self.SetStringItem(index, 1, label, 539 + self.InsertItem(index, "")
  540 + self.SetItem(index, 1, label,
541 imageId=self.mask_list_index[index]) 541 imageId=self.mask_list_index[index])
542 - self.SetStringItem(index, 2, threshold) 542 + self.SetItem(index, 2, threshold)
543 # self.SetItemImage(index, 1) 543 # self.SetItemImage(index, 1)
544 # for key in self.mask_list_index.keys(): 544 # for key in self.mask_list_index.keys():
545 # if key != index: 545 # if key != index:
@@ -553,7 +553,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckListCt @@ -553,7 +553,7 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckListCt
553 self.InsertNewItem(mask.index, mask.name, str(mask.threshold_range)) 553 self.InsertNewItem(mask.index, mask.name, str(mask.threshold_range))
554 554
555 def EditMaskThreshold(self, index, threshold_range): 555 def EditMaskThreshold(self, index, threshold_range):
556 - self.SetStringItem(index, 2, str(threshold_range)) 556 + self.SetItem(index, 2, str(threshold_range))
557 557
558 def EditMaskColour(self, index, colour): 558 def EditMaskColour(self, index, colour):
559 image = self.CreateColourBitmap(colour) 559 image = self.CreateColourBitmap(colour)
@@ -631,25 +631,25 @@ class SurfaceButtonControlPanel(wx.Panel): @@ -631,25 +631,25 @@ class SurfaceButtonControlPanel(wx.Panel):
631 BMP_NEW, 631 BMP_NEW,
632 style=button_style, 632 style=button_style,
633 size = wx.Size(24, 20)) 633 size = wx.Size(24, 20))
634 - button_new.SetToolTipString(_("Create a new surface")) 634 + button_new.SetToolTip(_("Create a new surface"))
635 635
636 button_remove = pbtn.PlateButton(self, BTN_REMOVE, "", 636 button_remove = pbtn.PlateButton(self, BTN_REMOVE, "",
637 BMP_REMOVE, 637 BMP_REMOVE,
638 style=button_style, 638 style=button_style,
639 size = wx.Size(24, 20)) 639 size = wx.Size(24, 20))
640 - button_remove.SetToolTipString(_("Remove surface")) 640 + button_remove.SetToolTip(_("Remove surface"))
641 641
642 button_duplicate = pbtn.PlateButton(self, BTN_DUPLICATE, "", 642 button_duplicate = pbtn.PlateButton(self, BTN_DUPLICATE, "",
643 BMP_DUPLICATE, 643 BMP_DUPLICATE,
644 style=button_style, 644 style=button_style,
645 size = wx.Size(24, 20)) 645 size = wx.Size(24, 20))
646 - button_duplicate.SetToolTipString(_("Duplicate surface")) 646 + button_duplicate.SetToolTip(_("Duplicate surface"))
647 647
648 button_open = pbtn.PlateButton(self, BTN_OPEN, "", 648 button_open = pbtn.PlateButton(self, BTN_OPEN, "",
649 BMP_OPEN, 649 BMP_OPEN,
650 style=button_style, 650 style=button_style,
651 size = wx.Size(24, 20)) 651 size = wx.Size(24, 20))
652 - button_open.SetToolTipString(_("Import a surface file into InVesalius")) 652 + button_open.SetToolTip(_("Import a surface file into InVesalius"))
653 653
654 # Add all controls to gui 654 # Add all controls to gui
655 sizer = wx.BoxSizer(wx.HORIZONTAL) 655 sizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -840,13 +840,13 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis @@ -840,13 +840,13 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis
840 self.imagelist = wx.ImageList(16, 16) 840 self.imagelist = wx.ImageList(16, 16)
841 841
842 image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg")) 842 image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg"))
843 - bitmap = wx.BitmapFromImage(image.Scale(16, 16)) 843 + bitmap = wx.Bitmap(image.Scale(16, 16))
844 bitmap.SetWidth(16) 844 bitmap.SetWidth(16)
845 bitmap.SetHeight(16) 845 bitmap.SetHeight(16)
846 img_null = self.imagelist.Add(bitmap) 846 img_null = self.imagelist.Add(bitmap)
847 847
848 image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg")) 848 image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg"))
849 - bitmap = wx.BitmapFromImage(image.Scale(16, 16)) 849 + bitmap = wx.Bitmap(image.Scale(16, 16))
850 bitmap.SetWidth(16) 850 bitmap.SetWidth(16)
851 bitmap.SetHeight(16) 851 bitmap.SetHeight(16)
852 img_check = self.imagelist.Add(bitmap) 852 img_check = self.imagelist.Add(bitmap)
@@ -923,23 +923,23 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis @@ -923,23 +923,23 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis
923 923
924 def InsertNewItem(self, index=0, label="Surface 1", volume="0 mm3", 924 def InsertNewItem(self, index=0, label="Surface 1", volume="0 mm3",
925 area="0 mm2", transparency="0%%", colour=None): 925 area="0 mm2", transparency="0%%", colour=None):
926 - self.InsertStringItem(index, "")  
927 - self.SetStringItem(index, 1, label, 926 + self.InsertItem(index, "")
  927 + self.SetItem(index, 1, label,
928 imageId = self.surface_list_index[index]) 928 imageId = self.surface_list_index[index])
929 - self.SetStringItem(index, 2, volume)  
930 - self.SetStringItem(index, 3, area)  
931 - self.SetStringItem(index, 4, transparency) 929 + self.SetItem(index, 2, volume)
  930 + self.SetItem(index, 3, area)
  931 + self.SetItem(index, 4, transparency)
932 self.SetItemImage(index, 1) 932 self.SetItemImage(index, 1)
933 933
934 def UpdateItemInfo(self, index=0, label="Surface 1", volume="0 mm3", 934 def UpdateItemInfo(self, index=0, label="Surface 1", volume="0 mm3",
935 area="0 mm2", transparency="0%%", colour=None): 935 area="0 mm2", transparency="0%%", colour=None):
936 print("UpdateItemInfo", index) 936 print("UpdateItemInfo", index)
937 # TODO: Retornar esse codigo 937 # TODO: Retornar esse codigo
938 - self.SetStringItem(index, 1, label, 938 + self.SetItem(index, 1, label,
939 imageId = self.surface_list_index[index]) 939 imageId = self.surface_list_index[index])
940 - self.SetStringItem(index, 2, volume)  
941 - self.SetStringItem(index, 3, area)  
942 - self.SetStringItem(index, 4, transparency) 940 + self.SetItem(index, 2, volume)
  941 + self.SetItem(index, 3, area)
  942 + self.SetItem(index, 4, transparency)
943 self.SetItemImage(index, 1) 943 self.SetItemImage(index, 1)
944 944
945 def CreateColourBitmap(self, colour): 945 def CreateColourBitmap(self, colour):
@@ -955,21 +955,21 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis @@ -955,21 +955,21 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis
955 for i in colour] 955 for i in colour]
956 new_image.putpixel((x,y), tuple(pixel_colour)) 956 new_image.putpixel((x,y), tuple(pixel_colour))
957 957
958 - wx_image = wx.EmptyImage(new_image.size[0],  
959 - new_image.size[1]) 958 + wx_image = wx.Image(new_image.size[0],
  959 + new_image.size[1])
960 try: 960 try:
961 wx_image.SetData(new_image.tostring()) 961 wx_image.SetData(new_image.tostring())
962 except Exception: 962 except Exception:
963 wx_image.SetData(new_image.tobytes()) 963 wx_image.SetData(new_image.tobytes())
964 964
965 - return wx.BitmapFromImage(wx_image.Scale(16, 16)) 965 + return wx.Bitmap(wx_image.Scale(16, 16))
966 966
967 def EditSurfaceTransparency(self, surface_index, transparency): 967 def EditSurfaceTransparency(self, surface_index, transparency):
968 """ 968 """
969 Set actor transparency (oposite to opacity) according to given actor 969 Set actor transparency (oposite to opacity) according to given actor
970 index and value. 970 index and value.
971 """ 971 """
972 - self.SetStringItem(surface_index, 4, "%d%%"%(int(transparency*100))) 972 + self.SetItem(surface_index, 4, "%d%%"%(int(transparency*100)))
973 973
974 def EditSurfaceColour(self, surface_index, colour): 974 def EditSurfaceColour(self, surface_index, colour):
975 """ 975 """
@@ -1115,13 +1115,13 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis @@ -1115,13 +1115,13 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis
1115 self.imagelist = wx.ImageList(16, 16) 1115 self.imagelist = wx.ImageList(16, 16)
1116 1116
1117 image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg")) 1117 image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg"))
1118 - bitmap = wx.BitmapFromImage(image.Scale(16, 16)) 1118 + bitmap = wx.Bitmap(image.Scale(16, 16))
1119 bitmap.SetWidth(16) 1119 bitmap.SetWidth(16)
1120 bitmap.SetHeight(16) 1120 bitmap.SetHeight(16)
1121 img_null = self.imagelist.Add(bitmap) 1121 img_null = self.imagelist.Add(bitmap)
1122 1122
1123 image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg")) 1123 image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg"))
1124 - bitmap = wx.BitmapFromImage(image.Scale(16, 16)) 1124 + bitmap = wx.Bitmap(image.Scale(16, 16))
1125 bitmap.SetWidth(16) 1125 bitmap.SetWidth(16)
1126 bitmap.SetHeight(16) 1126 bitmap.SetHeight(16)
1127 img_check = self.imagelist.Add(bitmap) 1127 img_check = self.imagelist.Add(bitmap)
@@ -1217,22 +1217,22 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis @@ -1217,22 +1217,22 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis
1217 1217
1218 def InsertNewItem(self, index=0, label="Measurement 1", colour=None, 1218 def InsertNewItem(self, index=0, label="Measurement 1", colour=None,
1219 location="SURFACE", type_="LINEAR", value="0 mm"): 1219 location="SURFACE", type_="LINEAR", value="0 mm"):
1220 - self.InsertStringItem(index, "")  
1221 - self.SetStringItem(index, 1, label, 1220 + self.InsertItem(index, "")
  1221 + self.SetItem(index, 1, label,
1222 imageId = self._list_index[index]) 1222 imageId = self._list_index[index])
1223 - self.SetStringItem(index, 2, location)  
1224 - self.SetStringItem(index, 3, type_)  
1225 - self.SetStringItem(index, 4, value) 1223 + self.SetItem(index, 2, location)
  1224 + self.SetItem(index, 3, type_)
  1225 + self.SetItem(index, 4, value)
1226 self.SetItemImage(index, 1) 1226 self.SetItemImage(index, 1)
1227 self.Refresh() 1227 self.Refresh()
1228 1228
1229 def UpdateItemInfo(self, index=0, label="Measurement 1", colour=None, 1229 def UpdateItemInfo(self, index=0, label="Measurement 1", colour=None,
1230 location="SURFACE", type_="LINEAR", value="0 mm"): 1230 location="SURFACE", type_="LINEAR", value="0 mm"):
1231 - self.SetStringItem(index, 1, label, 1231 + self.SetItem(index, 1, label,
1232 imageId = self._list_index[index]) 1232 imageId = self._list_index[index])
1233 - self.SetStringItem(index, 2, location)  
1234 - self.SetStringItem(index, 3, type_)  
1235 - self.SetStringItem(index, 4, value) 1233 + self.SetItem(index, 2, location)
  1234 + self.SetItem(index, 3, type_)
  1235 + self.SetItem(index, 4, value)
1236 self.SetItemImage(index, 1) 1236 self.SetItemImage(index, 1)
1237 self.Refresh() 1237 self.Refresh()
1238 1238
@@ -1249,13 +1249,13 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis @@ -1249,13 +1249,13 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.CheckLis
1249 for i in colour] 1249 for i in colour]
1250 new_image.putpixel((x,y), tuple(pixel_colour)) 1250 new_image.putpixel((x,y), tuple(pixel_colour))
1251 1251
1252 - wx_image = wx.EmptyImage(new_image.size[0],  
1253 - new_image.size[1]) 1252 + wx_image = wx.Image(new_image.size[0],
  1253 + new_image.size[1])
1254 try: 1254 try:
1255 wx_image.SetData(new_image.tostring()) 1255 wx_image.SetData(new_image.tostring())
1256 except: 1256 except:
1257 wx_image.SetData(new_image.tobytes()) 1257 wx_image.SetData(new_image.tobytes())
1258 - return wx.BitmapFromImage(wx_image.Scale(16, 16)) 1258 + return wx.Bitmap(wx_image.Scale(16, 16))
1259 1259
1260 def EditItemColour(self, measure_index, colour): 1260 def EditItemColour(self, measure_index, colour):
1261 """ 1261 """
@@ -1310,19 +1310,19 @@ class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.Check @@ -1310,19 +1310,19 @@ class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.Check
1310 self.imagelist = wx.ImageList(16, 16) 1310 self.imagelist = wx.ImageList(16, 16)
1311 1311
1312 image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg")) 1312 image = wx.Image(os.path.join(const.ICON_DIR, "object_visible.jpg"))
1313 - bitmap = wx.BitmapFromImage(image.Scale(16, 16)) 1313 + bitmap = wx.Bitmap(image.Scale(16, 16))
1314 bitmap.SetWidth(16) 1314 bitmap.SetWidth(16)
1315 bitmap.SetHeight(16) 1315 bitmap.SetHeight(16)
1316 img_check = self.imagelist.Add(bitmap) 1316 img_check = self.imagelist.Add(bitmap)
1317 1317
1318 image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg")) 1318 image = wx.Image(os.path.join(const.ICON_DIR, "object_invisible.jpg"))
1319 - bitmap = wx.BitmapFromImage(image.Scale(16, 16)) 1319 + bitmap = wx.Bitmap(image.Scale(16, 16))
1320 bitmap.SetWidth(16) 1320 bitmap.SetWidth(16)
1321 bitmap.SetHeight(16) 1321 bitmap.SetHeight(16)
1322 img_null = self.imagelist.Add(bitmap) 1322 img_null = self.imagelist.Add(bitmap)
1323 1323
1324 image = wx.Image(os.path.join(const.ICON_DIR, "object_colour.jpg")) 1324 image = wx.Image(os.path.join(const.ICON_DIR, "object_colour.jpg"))
1325 - bitmap = wx.BitmapFromImage(image.Scale(16, 16)) 1325 + bitmap = wx.Bitmap(image.Scale(16, 16))
1326 bitmap.SetWidth(16) 1326 bitmap.SetWidth(16)
1327 bitmap.SetHeight(16) 1327 bitmap.SetHeight(16)
1328 self.img_colour = self.imagelist.Add(bitmap) 1328 self.img_colour = self.imagelist.Add(bitmap)
@@ -1342,10 +1342,10 @@ class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.Check @@ -1342,10 +1342,10 @@ class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin, listmix.Check
1342 1342
1343 def InsertNewItem(self, index=0, name="Axial 1", type_="2d", 1343 def InsertNewItem(self, index=0, name="Axial 1", type_="2d",
1344 value="bla", colour=None): 1344 value="bla", colour=None):
1345 - self.InsertStringItem(index, "")  
1346 - self.SetStringItem(index, 1, name, imageId = self.img_colour)  
1347 - self.SetStringItem(index, 2, type_)  
1348 - self.SetStringItem(index, 3, value) 1345 + self.InsertItem(index, "")
  1346 + self.SetItem(index, 1, name, imageId = self.img_colour)
  1347 + self.SetItem(index, 2, type_)
  1348 + self.SetItem(index, 3, value)
1349 1349
1350 def Populate(self): 1350 def Populate(self):
1351 dict = ((0, "Axial 1", "2D", "blalbalblabllablalbla"), 1351 dict = ((0, "Axial 1", "2D", "blalbalblabllablalbla"),
invesalius/gui/default_tasks.py
@@ -58,12 +58,12 @@ zzW\xcff&amp;\xb8,\x89\xa8@Q\xd6\xaaf\xdfRm,\xee\xb1BDxr#\xae\xf5|\xddo\xd6\xe2H\ @@ -58,12 +58,12 @@ zzW\xcff&amp;\xb8,\x89\xa8@Q\xd6\xaaf\xdfRm,\xee\xb1BDxr#\xae\xf5|\xddo\xd6\xe2H\
58 \x00\x00\x00IEND\xaeB`\x82' 58 \x00\x00\x00IEND\xaeB`\x82'
59 59
60 def GetCollapsedIconBitmap(): 60 def GetCollapsedIconBitmap():
61 - return wx.BitmapFromImage(GetCollapsedIconImage()) 61 + return wx.Bitmap(GetCollapsedIconImage())
62 62
63 def GetCollapsedIconImage(): 63 def GetCollapsedIconImage():
64 from io import BytesIO 64 from io import BytesIO
65 stream = BytesIO(GetCollapsedIconData()) 65 stream = BytesIO(GetCollapsedIconData())
66 - return wx.ImageFromStream(stream) 66 + return wx.Image(stream)
67 67
68 def GetExpandedIconData(): 68 def GetExpandedIconData():
69 return \ 69 return \
@@ -89,12 +89,12 @@ b&#39;\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ @@ -89,12 +89,12 @@ b&#39;\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
89 `\x82' 89 `\x82'
90 90
91 def GetExpandedIconBitmap(): 91 def GetExpandedIconBitmap():
92 - return wx.BitmapFromImage(GetExpandedIconImage()) 92 + return wx.Bitmap(GetExpandedIconImage())
93 93
94 def GetExpandedIconImage(): 94 def GetExpandedIconImage():
95 from io import BytesIO 95 from io import BytesIO
96 stream = BytesIO(GetExpandedIconData()) 96 stream = BytesIO(GetExpandedIconData())
97 - return wx.ImageFromStream(stream) 97 + return wx.Image(stream)
98 98
99 99
100 # Main panel 100 # Main panel
invesalius/gui/default_viewers.py
@@ -506,7 +506,7 @@ class VolumeToolPanel(wx.Panel): @@ -506,7 +506,7 @@ class VolumeToolPanel(wx.Panel):
506 for name in const.RAYCASTING_TYPES: 506 for name in const.RAYCASTING_TYPES:
507 id = wx.NewId() 507 id = wx.NewId()
508 item = wx.MenuItem(menu, id, name, kind=wx.ITEM_RADIO) 508 item = wx.MenuItem(menu, id, name, kind=wx.ITEM_RADIO)
509 - menu.AppendItem(item) 509 + menu.Append(item)
510 if name == const.RAYCASTING_OFF_LABEL: 510 if name == const.RAYCASTING_OFF_LABEL:
511 self.off_item = item 511 self.off_item = item
512 item.Check(1) 512 item.Check(1)
@@ -522,12 +522,12 @@ class VolumeToolPanel(wx.Panel): @@ -522,12 +522,12 @@ class VolumeToolPanel(wx.Panel):
522 self.id_cutplane = id 522 self.id_cutplane = id
523 523
524 item = wx.MenuItem(submenu, id, name, kind=wx.ITEM_CHECK) 524 item = wx.MenuItem(submenu, id, name, kind=wx.ITEM_CHECK)
525 - submenu.AppendItem(item) 525 + submenu.Append(item)
526 ID_TO_TOOL[id] = name 526 ID_TO_TOOL[id] = name
527 ID_TO_TOOL_ITEM[id] = item 527 ID_TO_TOOL_ITEM[id] = item
528 TOOL_STATE[id] = False 528 TOOL_STATE[id] = False
529 self.submenu_raycasting_tools = submenu 529 self.submenu_raycasting_tools = submenu
530 - menu.AppendMenu(RAYCASTING_TOOLS, _("Tools"), submenu) 530 + menu.Append(RAYCASTING_TOOLS, _("Tools"), submenu)
531 menu.Enable(RAYCASTING_TOOLS, 0) 531 menu.Enable(RAYCASTING_TOOLS, 0)
532 532
533 self.menu_raycasting = menu 533 self.menu_raycasting = menu
@@ -544,7 +544,7 @@ class VolumeToolPanel(wx.Panel): @@ -544,7 +544,7 @@ class VolumeToolPanel(wx.Panel):
544 bmp = wx.Bitmap(ID_TO_BMP[id][1], wx.BITMAP_TYPE_PNG) 544 bmp = wx.Bitmap(ID_TO_BMP[id][1], wx.BITMAP_TYPE_PNG)
545 item = wx.MenuItem(menu, id, ID_TO_BMP[id][0]) 545 item = wx.MenuItem(menu, id, ID_TO_BMP[id][0])
546 item.SetBitmap(bmp) 546 item.SetBitmap(bmp)
547 - menu.AppendItem(item) 547 + menu.Append(item)
548 menu.Bind(wx.EVT_MENU, self.OnMenuView) 548 menu.Bind(wx.EVT_MENU, self.OnMenuView)
549 self.menu_view = menu 549 self.menu_view = menu
550 550
@@ -558,7 +558,7 @@ class VolumeToolPanel(wx.Panel): @@ -558,7 +558,7 @@ class VolumeToolPanel(wx.Panel):
558 item = wx.MenuItem(slice_plane_menu, new_id, value, 558 item = wx.MenuItem(slice_plane_menu, new_id, value,
559 kind = wx.ITEM_CHECK) 559 kind = wx.ITEM_CHECK)
560 ID_TO_ITEMSLICEMENU[new_id] = item 560 ID_TO_ITEMSLICEMENU[new_id] = item
561 - slice_plane_menu.AppendItem(item) 561 + slice_plane_menu.Append(item)
562 562
563 slice_plane_menu.Bind(wx.EVT_MENU, self.OnMenuPlaneSlice) 563 slice_plane_menu.Bind(wx.EVT_MENU, self.OnMenuPlaneSlice)
564 564
@@ -577,7 +577,7 @@ class VolumeToolPanel(wx.Panel): @@ -577,7 +577,7 @@ class VolumeToolPanel(wx.Panel):
577 577
578 ID_TO_ITEM_3DSTEREO[new_id] = item 578 ID_TO_ITEM_3DSTEREO[new_id] = item
579 ID_TO_STEREO_NAME[new_id] = value 579 ID_TO_STEREO_NAME[new_id] = value
580 - stereo_menu.AppendItem(item) 580 + stereo_menu.Append(item)
581 581
582 stereo_menu.Bind(wx.EVT_MENU, self.OnMenuStereo) 582 stereo_menu.Bind(wx.EVT_MENU, self.OnMenuStereo)
583 583
invesalius/gui/dialogs.py
@@ -48,6 +48,7 @@ from wx.lib.agw import floatspin @@ -48,6 +48,7 @@ from wx.lib.agw import floatspin
48 from wx.lib.wordwrap import wordwrap 48 from wx.lib.wordwrap import wordwrap
49 from wx.lib.pubsub import pub as Publisher 49 from wx.lib.pubsub import pub as Publisher
50 50
  51 +
51 try: 52 try:
52 from wx.adv import AboutDialogInfo, AboutBox 53 from wx.adv import AboutDialogInfo, AboutBox
53 except ImportError: 54 except ImportError:
@@ -58,6 +59,7 @@ import invesalius.data.coordinates as dco @@ -58,6 +59,7 @@ import invesalius.data.coordinates as dco
58 import invesalius.gui.widgets.gradient as grad 59 import invesalius.gui.widgets.gradient as grad
59 import invesalius.session as ses 60 import invesalius.session as ses
60 import invesalius.utils as utils 61 import invesalius.utils as utils
  62 +from invesalius.gui.widgets.inv_spinctrl import InvSpinCtrl, InvFloatSpinCtrl
61 from invesalius.gui.widgets import clut_imagedata 63 from invesalius.gui.widgets import clut_imagedata
62 from invesalius.gui.widgets.clut_imagedata import CLUTImageDataWidget, EVT_CLUT_NODE_CHANGED 64 from invesalius.gui.widgets.clut_imagedata import CLUTImageDataWidget, EVT_CLUT_NODE_CHANGED
63 import numpy as np 65 import numpy as np
@@ -78,16 +80,9 @@ EVT_MASK_SET = wx.PyEventBinder(myEVT_MASK_SET, 1) @@ -78,16 +80,9 @@ EVT_MASK_SET = wx.PyEventBinder(myEVT_MASK_SET, 1)
78 80
79 class NumberDialog(wx.Dialog): 81 class NumberDialog(wx.Dialog):
80 def __init__(self, message, value=0): 82 def __init__(self, message, value=0):
81 - try:  
82 - pre = wx.PreDialog()  
83 - pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize,  
84 - pos=wx.DefaultPosition,  
85 - style=wx.DEFAULT_DIALOG_STYLE)  
86 - self.PostCreate(pre)  
87 - except AttributeError:  
88 - wx.Dialog.__init__(self, None, -1, "InVesalius 3", size=wx.DefaultSize,  
89 - pos=wx.DefaultPosition,  
90 - style=wx.DEFAULT_DIALOG_STYLE) 83 + wx.Dialog.__init__(self, None, -1, "InVesalius 3", size=wx.DefaultSize,
  84 + pos=wx.DefaultPosition,
  85 + style=wx.DEFAULT_DIALOG_STYLE)
91 86
92 # Static text which contains message to user 87 # Static text which contains message to user
93 label = wx.StaticText(self, -1, message) 88 label = wx.StaticText(self, -1, message)
@@ -133,16 +128,9 @@ class NumberDialog(wx.Dialog): @@ -133,16 +128,9 @@ class NumberDialog(wx.Dialog):
133 class ResizeImageDialog(wx.Dialog): 128 class ResizeImageDialog(wx.Dialog):
134 129
135 def __init__(self):#, message, value=0): 130 def __init__(self):#, message, value=0):
136 - try:  
137 - pre = self.pre = wx.PreDialog()  
138 - pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize,  
139 - pos=wx.DefaultPosition,  
140 - style=wx.DEFAULT_DIALOG_STYLE)  
141 - self.PostCreate(pre)  
142 - except AttributeError:  
143 - wx.Dialog.__init__(self, None, -1, "InVesalius 3", size=wx.DefaultSize,  
144 - pos=wx.DefaultPosition,  
145 - style=wx.DEFAULT_DIALOG_STYLE) 131 + wx.Dialog.__init__(self, None, -1, "InVesalius 3", size=wx.DefaultSize,
  132 + pos=wx.DefaultPosition,
  133 + style=wx.DEFAULT_DIALOG_STYLE)
146 134
147 lbl_message = wx.StaticText(self, -1, _("InVesalius is running on a 32-bit operating system or has insufficient memory. \nIf you want to work with 3D surfaces or volume rendering, \nit is recommended to reduce the medical images resolution.")) 135 lbl_message = wx.StaticText(self, -1, _("InVesalius is running on a 32-bit operating system or has insufficient memory. \nIf you want to work with 3D surfaces or volume rendering, \nit is recommended to reduce the medical images resolution."))
148 icon = wx.ArtProvider.GetBitmap(wx.ART_WARNING, wx.ART_MESSAGE_BOX, (32,32)) 136 icon = wx.ArtProvider.GetBitmap(wx.ART_WARNING, wx.ART_MESSAGE_BOX, (32,32))
@@ -160,8 +148,7 @@ class ResizeImageDialog(wx.Dialog): @@ -160,8 +148,7 @@ class ResizeImageDialog(wx.Dialog):
160 148
161 lbl_message_percent = wx.StaticText(self, -1,_("Percentage of original resolution")) 149 lbl_message_percent = wx.StaticText(self, -1,_("Percentage of original resolution"))
162 150
163 - num_ctrl_percent = wx.SpinCtrl(self, -1)  
164 - num_ctrl_percent.SetRange(20,100) 151 + num_ctrl_percent = InvSpinCtrl(self, -1, value=100, min_value=20, max_value=100)
165 self.num_ctrl_porcent = num_ctrl_percent 152 self.num_ctrl_porcent = num_ctrl_percent
166 153
167 sizer_percent = wx.BoxSizer(wx.HORIZONTAL) 154 sizer_percent = wx.BoxSizer(wx.HORIZONTAL)
@@ -675,14 +662,8 @@ def ShowLoadRegistrationDialog(): @@ -675,14 +662,8 @@ def ShowLoadRegistrationDialog():
675 662
676 class MessageDialog(wx.Dialog): 663 class MessageDialog(wx.Dialog):
677 def __init__(self, message): 664 def __init__(self, message):
678 - try:  
679 - pre = wx.PreDialog()  
680 - pre.Create(None, -1, "InVesalius 3", size=(360, 370), pos=wx.DefaultPosition,  
681 - style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)  
682 - self.PostCreate(pre)  
683 - except AttributeError:  
684 - wx.Dialog.__init__(self, None, -1, "InVesalius 3", size=(360, 370), pos=wx.DefaultPosition,  
685 - style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION) 665 + wx.Dialog.__init__(self, None, -1, "InVesalius 3", size=(360, 370), pos=wx.DefaultPosition,
  666 + style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)
686 667
687 # Static text which contains message to user 668 # Static text which contains message to user
688 label = wx.StaticText(self, -1, message) 669 label = wx.StaticText(self, -1, message)
@@ -721,14 +702,8 @@ class UpdateMessageDialog(wx.Dialog): @@ -721,14 +702,8 @@ class UpdateMessageDialog(wx.Dialog):
721 title=_("Invesalius Update") 702 title=_("Invesalius Update")
722 self.url = url 703 self.url = url
723 704
724 - try:  
725 - pre = wx.PreDialog()  
726 - pre.Create(None, -1, title, size=(360, 370), pos=wx.DefaultPosition,  
727 - style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)  
728 - self.PostCreate(pre)  
729 - except AttributeError:  
730 - wx.Dialog.__init__(self, None, -1, title, size=(360, 370), pos=wx.DefaultPosition,  
731 - style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION) 705 + wx.Dialog.__init__(self, None, -1, title, size=(360, 370), pos=wx.DefaultPosition,
  706 + style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)
732 707
733 # Static text which contains message to user 708 # Static text which contains message to user
734 label = wx.StaticText(self, -1, msg) 709 label = wx.StaticText(self, -1, msg)
@@ -1066,22 +1041,8 @@ class NewMask(wx.Dialog): @@ -1066,22 +1041,8 @@ class NewMask(wx.Dialog):
1066 import invesalius.data.mask as mask 1041 import invesalius.data.mask as mask
1067 import invesalius.project as prj 1042 import invesalius.project as prj
1068 1043
1069 - try:  
1070 - # Instead of calling wx.Dialog.__init__ we precreate the dialog  
1071 - # so we can set an extra style that must be set before  
1072 - # creation, and then we create the GUI object using the Create  
1073 - # method.  
1074 - pre = wx.PreDialog()  
1075 - pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)  
1076 - pre.Create(parent, ID, title, pos, (500,300), style)  
1077 - # This next step is the most important, it turns this Python  
1078 - # object into the real wrapper of the dialog (instead of pre)  
1079 - # as far as the wxPython extension is concerned.  
1080 - self.PostCreate(pre)  
1081 - except AttributeError:  
1082 - wx.Dialog.__init__(self, parent, ID, title, pos, (500,300), style)  
1083 - self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)  
1084 - 1044 + wx.Dialog.__init__(self, parent, ID, title, pos, style=style)
  1045 + self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
1085 1046
1086 self.CenterOnScreen() 1047 self.CenterOnScreen()
1087 1048
@@ -1127,10 +1088,10 @@ class NewMask(wx.Dialog): @@ -1127,10 +1088,10 @@ class NewMask(wx.Dialog):
1127 self.colour = original_colour 1088 self.colour = original_colour
1128 colour = [255*i for i in original_colour] 1089 colour = [255*i for i in original_colour]
1129 colour.append(100) 1090 colour.append(100)
1130 - gradient = grad.GradientSlider(self, -1, int(bound_min),  
1131 - int(bound_max),  
1132 - int(thresh_min), int(thresh_max),  
1133 - colour) 1091 + gradient = grad.GradientCtrl(self, -1, int(bound_min),
  1092 + int(bound_max),
  1093 + int(thresh_min), int(thresh_max),
  1094 + colour)
1134 self.gradient = gradient 1095 self.gradient = gradient
1135 1096
1136 # OVERVIEW 1097 # OVERVIEW
@@ -1162,11 +1123,12 @@ class NewMask(wx.Dialog): @@ -1162,11 +1123,12 @@ class NewMask(wx.Dialog):
1162 # Merge all sizers and checkboxes 1123 # Merge all sizers and checkboxes
1163 sizer = wx.BoxSizer(wx.VERTICAL) 1124 sizer = wx.BoxSizer(wx.VERTICAL)
1164 sizer.Add(fixed_sizer, 0, wx.ALL|wx.GROW|wx.EXPAND, 15) 1125 sizer.Add(fixed_sizer, 0, wx.ALL|wx.GROW|wx.EXPAND, 15)
1165 - sizer.Add(gradient, 1, wx.BOTTOM|wx.RIGHT|wx.LEFT|wx.EXPAND|wx.GROW, 20) 1126 + sizer.Add(gradient, 0, wx.BOTTOM|wx.RIGHT|wx.LEFT|wx.EXPAND|wx.GROW, 20)
1166 sizer.Add(btnsizer, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 10) 1127 sizer.Add(btnsizer, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 10)
1167 1128
1168 self.SetSizer(sizer) 1129 self.SetSizer(sizer)
1169 sizer.Fit(self) 1130 sizer.Fit(self)
  1131 + self.Layout()
1170 1132
1171 self.Bind(grad.EVT_THRESHOLD_CHANGED, self.OnSlideChanged, self.gradient) 1133 self.Bind(grad.EVT_THRESHOLD_CHANGED, self.OnSlideChanged, self.gradient)
1172 self.combo_thresh.Bind(wx.EVT_COMBOBOX, self.OnComboThresh) 1134 self.combo_thresh.Bind(wx.EVT_COMBOBOX, self.OnComboThresh)
@@ -1362,22 +1324,8 @@ class NewSurfaceDialog(wx.Dialog): @@ -1362,22 +1324,8 @@ class NewSurfaceDialog(wx.Dialog):
1362 import invesalius.data.surface as surface 1324 import invesalius.data.surface as surface
1363 import invesalius.project as prj 1325 import invesalius.project as prj
1364 1326
1365 - try:  
1366 - # Instead of calling wx.Dialog.__init__ we precreate the dialog  
1367 - # so we can set an extra style that must be set before  
1368 - # creation, and then we create the GUI object using the Create  
1369 - # method.  
1370 - pre = wx.PreDialog()  
1371 - pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)  
1372 - pre.Create(parent, ID, title, pos, (500,300), style)  
1373 -  
1374 - # This next step is the most important, it turns this Python  
1375 - # object into the real wrapper of the dialog (instead of pre)  
1376 - # as far as the wxPython extension is concerned.  
1377 - self.PostCreate(pre)  
1378 - except AttributeError:  
1379 - wx.Dialog.__init__(self, parent, ID, title, pos, (500,300), style)  
1380 - self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) 1327 + wx.Dialog.__init__(self, parent, ID, title, pos, (500,300), style)
  1328 + self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
1381 1329
1382 self.CenterOnScreen() 1330 self.CenterOnScreen()
1383 1331
@@ -1579,28 +1527,10 @@ class SurfaceCreationDialog(wx.Dialog): @@ -1579,28 +1527,10 @@ class SurfaceCreationDialog(wx.Dialog):
1579 style=wx.DEFAULT_DIALOG_STYLE, useMetal=False, 1527 style=wx.DEFAULT_DIALOG_STYLE, useMetal=False,
1580 mask_edited=False): 1528 mask_edited=False):
1581 1529
1582 - # Instead of calling wx.Dialog.__init__ we precreate the dialog  
1583 - # so we can set an extra style that must be set before  
1584 - # creation, and then we create the GUI object using the Create  
1585 - # method.  
1586 - try:  
1587 - pre = wx.PreDialog()  
1588 - pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)  
1589 - pre.Create(parent, ID, title, pos, (500,300), style)  
1590 -  
1591 - # This extra style can be set after the UI object has been created.  
1592 - if 'wxMac' in wx.PlatformInfo and useMetal:  
1593 - self.SetExtraStyle(wx.DIALOG_EX_METAL)  
1594 -  
1595 - # This next step is the most important, it turns this Python  
1596 - # object into the real wrapper of the dialog (instead of pre)  
1597 - # as far as the wxPython extension is concerned.  
1598 - self.PostCreate(pre)  
1599 - except AttributeError:  
1600 - wx.Dialog.__init__(self, parent, ID, title, pos, size, style)  
1601 - self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)  
1602 - if 'wxMac' in wx.PlatformInfo and useMetal:  
1603 - self.SetExtraStyle(wx.DIALOG_EX_METAL) 1530 + wx.Dialog.__init__(self, parent, ID, title, pos, size, style)
  1531 + self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
  1532 + if 'wxMac' in wx.PlatformInfo and useMetal:
  1533 + self.SetExtraStyle(wx.DIALOG_EX_METAL)
1604 1534
1605 self.CenterOnScreen() 1535 self.CenterOnScreen()
1606 1536
@@ -1772,19 +1702,19 @@ class CAOptions(wx.Panel): @@ -1772,19 +1702,19 @@ class CAOptions(wx.Panel):
1772 1702
1773 def _build_widgets(self): 1703 def _build_widgets(self):
1774 sb = wx.StaticBox(self, -1, _('Options')) 1704 sb = wx.StaticBox(self, -1, _('Options'))
1775 - self.angle = floatspin.FloatSpin(self, -1, value=0.7, min_val=0.0,  
1776 - max_val=1.0, increment=0.1,  
1777 - digits=1) 1705 + self.angle = InvFloatSpinCtrl(self, -1, value=0.7, min_value=0.0,
  1706 + max_value=1.0, increment=0.1,
  1707 + digits=1)
1778 1708
1779 - self.max_distance = floatspin.FloatSpin(self, -1, value=3.0, min_val=0.0,  
1780 - max_val=100.0, increment=0.1, 1709 + self.max_distance = InvFloatSpinCtrl(self, -1, value=3.0, min_value=0.0,
  1710 + max_value=100.0, increment=0.1,
1781 digits=2) 1711 digits=2)
1782 1712
1783 - self.min_weight = floatspin.FloatSpin(self, -1, value=0.5, min_val=0.0,  
1784 - max_val=1.0, increment=0.1, 1713 + self.min_weight = InvFloatSpinCtrl(self, -1, value=0.5, min_value=0.0,
  1714 + max_value=1.0, increment=0.1,
1785 digits=1) 1715 digits=1)
1786 1716
1787 - self.steps = wx.SpinCtrl(self, -1, value='10', min=1, max=100) 1717 + self.steps = InvSpinCtrl(self, -1, value=10, min_value=1, max_value=100)
1788 1718
1789 layout_sizer = wx.FlexGridSizer(rows=4, cols=2, hgap=5, vgap=5) 1719 layout_sizer = wx.FlexGridSizer(rows=4, cols=2, hgap=5, vgap=5)
1790 layout_sizer.Add(wx.StaticText(self, -1, _(u'Angle:')), 0, wx.EXPAND) 1720 layout_sizer.Add(wx.StaticText(self, -1, _(u'Angle:')), 0, wx.EXPAND)
@@ -1826,12 +1756,12 @@ class SurfaceMethodPanel(wx.Panel): @@ -1826,12 +1756,12 @@ class SurfaceMethodPanel(wx.Panel):
1826 choices=[i for i in sorted(self.alg_types) 1756 choices=[i for i in sorted(self.alg_types)
1827 if not (self.mask_edited and i in self.edited_imp)], 1757 if not (self.mask_edited and i in self.edited_imp)],
1828 style=wx.CB_READONLY) 1758 style=wx.CB_READONLY)
1829 - w, h = self.cb_types.GetSizeTuple() 1759 + w, h = self.cb_types.GetSize()
1830 1760
1831 icon = wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_MESSAGE_BOX, 1761 icon = wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_MESSAGE_BOX,
1832 (h * 0.8, h * 0.8)) 1762 (h * 0.8, h * 0.8))
1833 self.bmp = wx.StaticBitmap(self, -1, icon) 1763 self.bmp = wx.StaticBitmap(self, -1, icon)
1834 - self.bmp.SetToolTipString(_("It is not possible to use the Default method because the mask was edited.")) 1764 + self.bmp.SetToolTip(_("It is not possible to use the Default method because the mask was edited."))
1835 1765
1836 self.method_sizer = wx.BoxSizer(wx.HORIZONTAL) 1766 self.method_sizer = wx.BoxSizer(wx.HORIZONTAL)
1837 self.method_sizer.Add(wx.StaticText(self, -1, _(u'Method:')), 0, 1767 self.method_sizer.Add(wx.StaticText(self, -1, _(u'Method:')), 0,
@@ -1906,12 +1836,7 @@ class SurfaceMethodPanel(wx.Panel): @@ -1906,12 +1836,7 @@ class SurfaceMethodPanel(wx.Panel):
1906 1836
1907 class ClutImagedataDialog(wx.Dialog): 1837 class ClutImagedataDialog(wx.Dialog):
1908 def __init__(self, histogram, init, end, nodes=None): 1838 def __init__(self, histogram, init, end, nodes=None):
1909 - try:  
1910 - pre = wx.PreDialog()  
1911 - pre.Create(wx.GetApp().GetTopWindow(), -1, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)  
1912 - self.PostCreate(pre)  
1913 - except AttributeError:  
1914 - wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP) 1839 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)
1915 1840
1916 self.histogram = histogram 1841 self.histogram = histogram
1917 self.init = init 1842 self.init = init
@@ -1981,8 +1906,8 @@ class WatershedOptionsPanel(wx.Panel): @@ -1981,8 +1906,8 @@ class WatershedOptionsPanel(wx.Panel):
1981 style=wx.NO_BORDER | wx.HORIZONTAL) 1906 style=wx.NO_BORDER | wx.HORIZONTAL)
1982 self.choice_3dcon.SetSelection(self.con3d_choices.index(self.config.con_3d)) 1907 self.choice_3dcon.SetSelection(self.con3d_choices.index(self.config.con_3d))
1983 1908
1984 - self.gaussian_size = wx.SpinCtrl(self, -1, "", min=1, max=10)  
1985 - self.gaussian_size.SetValue(self.config.mg_size) 1909 + self.gaussian_size = InvSpinCtrl(self, -1, value=self.config.mg_size,
  1910 + min_value=1, max_value=10)
1986 1911
1987 box_sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Conectivity"), wx.VERTICAL) 1912 box_sizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Conectivity"), wx.VERTICAL)
1988 box_sizer.Add(self.choice_2dcon, 0, wx.ALIGN_CENTER_VERTICAL,2) 1913 box_sizer.Add(self.choice_2dcon, 0, wx.ALIGN_CENTER_VERTICAL,2)
@@ -2010,12 +1935,7 @@ class WatershedOptionsPanel(wx.Panel): @@ -2010,12 +1935,7 @@ class WatershedOptionsPanel(wx.Panel):
2010 1935
2011 class WatershedOptionsDialog(wx.Dialog): 1936 class WatershedOptionsDialog(wx.Dialog):
2012 def __init__(self, config, ID=-1, title=_(u'Watershed'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP): 1937 def __init__(self, config, ID=-1, title=_(u'Watershed'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP):
2013 - try:  
2014 - pre = wx.PreDialog()  
2015 - pre.Create(wx.GetApp().GetTopWindow(), ID, title=title, style=style)  
2016 - self.PostCreate(pre)  
2017 - except AttributeError:  
2018 - wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style) 1938 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style)
2019 1939
2020 self.config = config 1940 self.config = config
2021 1941
@@ -2054,12 +1974,7 @@ class WatershedOptionsDialog(wx.Dialog): @@ -2054,12 +1974,7 @@ class WatershedOptionsDialog(wx.Dialog):
2054 1974
2055 class MaskBooleanDialog(wx.Dialog): 1975 class MaskBooleanDialog(wx.Dialog):
2056 def __init__(self, masks, ID=-1, title=_(u"Boolean operations"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP): 1976 def __init__(self, masks, ID=-1, title=_(u"Boolean operations"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP):
2057 - try:  
2058 - pre = wx.PreDialog()  
2059 - pre.Create(wx.GetApp().GetTopWindow(), ID, title=title, style=style)  
2060 - self.PostCreate(pre)  
2061 - except AttributeError:  
2062 - wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style) 1977 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style)
2063 1978
2064 self._init_gui(masks) 1979 self._init_gui(masks)
2065 self.CenterOnScreen() 1980 self.CenterOnScreen()
@@ -2138,12 +2053,7 @@ class MaskBooleanDialog(wx.Dialog): @@ -2138,12 +2053,7 @@ class MaskBooleanDialog(wx.Dialog):
2138 2053
2139 class ReorientImageDialog(wx.Dialog): 2054 class ReorientImageDialog(wx.Dialog):
2140 def __init__(self, ID=-1, title=_(u'Image reorientation'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP): 2055 def __init__(self, ID=-1, title=_(u'Image reorientation'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP):
2141 - try:  
2142 - pre = wx.PreDialog()  
2143 - pre.Create(wx.GetApp().GetTopWindow(), ID, title=title, style=style)  
2144 - self.PostCreate(pre)  
2145 - except AttributeError:  
2146 - wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style) 2056 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style)
2147 2057
2148 self._closed = False 2058 self._closed = False
2149 2059
@@ -2263,16 +2173,10 @@ class ImportBitmapParameters(wx.Dialog): @@ -2263,16 +2173,10 @@ class ImportBitmapParameters(wx.Dialog):
2263 else: 2173 else:
2264 size=wx.Size(380,210) 2174 size=wx.Size(380,210)
2265 2175
2266 - try:  
2267 - pre = wx.PreDialog()  
2268 - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Create project from bitmap"),size=size,  
2269 - style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)  
2270 - self.PostCreate(pre)  
2271 - except AttributeError:  
2272 - wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1,  
2273 - _(u"Create project from bitmap"),  
2274 - size=size,  
2275 - style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP) 2176 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1,
  2177 + _(u"Create project from bitmap"),
  2178 + size=size,
  2179 + style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)
2276 2180
2277 self.interval = 0 2181 self.interval = 0
2278 2182
@@ -2325,16 +2229,16 @@ class ImportBitmapParameters(wx.Dialog): @@ -2325,16 +2229,16 @@ class ImportBitmapParameters(wx.Dialog):
2325 gbs_spacing = wx.GridBagSizer(2, 6) 2229 gbs_spacing = wx.GridBagSizer(2, 6)
2326 2230
2327 stx_spacing_x = stx_spacing_x = wx.StaticText(p, -1, _(u"X:")) 2231 stx_spacing_x = stx_spacing_x = wx.StaticText(p, -1, _(u"X:"))
2328 - fsp_spacing_x = self.fsp_spacing_x = FS.FloatSpin(p, -1, min_val=0,\ 2232 + fsp_spacing_x = self.fsp_spacing_x = InvFloatSpinCtrl(p, -1, min_value=0, max_value=1000000000,
2329 increment=0.25, value=1.0, digits=8) 2233 increment=0.25, value=1.0, digits=8)
2330 2234
2331 2235
2332 stx_spacing_y = stx_spacing_y = wx.StaticText(p, -1, _(u"Y:")) 2236 stx_spacing_y = stx_spacing_y = wx.StaticText(p, -1, _(u"Y:"))
2333 - fsp_spacing_y = self.fsp_spacing_y = FS.FloatSpin(p, -1, min_val=0,\ 2237 + fsp_spacing_y = self.fsp_spacing_y = InvFloatSpinCtrl(p, -1, min_value=0, max_value=1000000000,
2334 increment=0.25, value=1.0, digits=8) 2238 increment=0.25, value=1.0, digits=8)
2335 2239
2336 stx_spacing_z = stx_spacing_z = wx.StaticText(p, -1, _(u"Z:")) 2240 stx_spacing_z = stx_spacing_z = wx.StaticText(p, -1, _(u"Z:"))
2337 - fsp_spacing_z = self.fsp_spacing_z = FS.FloatSpin(p, -1, min_val=0,\ 2241 + fsp_spacing_z = self.fsp_spacing_z = InvFloatSpinCtrl(p, -1, min_value=0, max_value=1000000000,
2338 increment=0.25, value=1.0, digits=8) 2242 increment=0.25, value=1.0, digits=8)
2339 2243
2340 2244
@@ -2594,12 +2498,11 @@ class PanelFFillDynamic(wx.Panel): @@ -2594,12 +2498,11 @@ class PanelFFillDynamic(wx.Panel):
2594 self.use_ww_wl = wx.CheckBox(self, -1, _(u"Use WW&WL")) 2498 self.use_ww_wl = wx.CheckBox(self, -1, _(u"Use WW&WL"))
2595 self.use_ww_wl.SetValue(self.config.use_ww_wl) 2499 self.use_ww_wl.SetValue(self.config.use_ww_wl)
2596 2500
2597 - self.deviation_min = wx.SpinCtrl(self, -1, value='%d' % self.config.dev_min, min=0, max=10000)  
2598 - w, h = self.deviation_min.GetTextExtent('M')  
2599 - self.deviation_min.SetMinSize((w*5, -1)) 2501 + self.deviation_min = InvSpinCtrl(self, -1, value=self.config.dev_min, min_value=0, max_value=10000)
  2502 + self.deviation_min.CalcSizeFromTextSize()
2600 2503
2601 - self.deviation_max = wx.SpinCtrl(self, -1, value='%d' % self.config.dev_max, min=0, max=10000)  
2602 - self.deviation_max.SetMinSize((w*5, -1)) 2504 + self.deviation_max = InvSpinCtrl(self, -1, value=self.config.dev_max, min_value=0, max_value=10000)
  2505 + self.deviation_max.CalcSizeFromTextSize()
2603 2506
2604 sizer = wx.GridBagSizer(5, 5) 2507 sizer = wx.GridBagSizer(5, 5)
2605 2508
@@ -2656,17 +2559,16 @@ class PanelFFillConfidence(wx.Panel): @@ -2656,17 +2559,16 @@ class PanelFFillConfidence(wx.Panel):
2656 self.use_ww_wl = wx.CheckBox(self, -1, _(u"Use WW&WL")) 2559 self.use_ww_wl = wx.CheckBox(self, -1, _(u"Use WW&WL"))
2657 self.use_ww_wl.SetValue(self.config.use_ww_wl) 2560 self.use_ww_wl.SetValue(self.config.use_ww_wl)
2658 2561
2659 - self.spin_mult = floatspin.FloatSpin(self, -1,  
2660 - value=self.config.confid_mult,  
2661 - min_val=1.0, max_val=10.0,  
2662 - increment=0.1, digits=1,  
2663 - style=wx.TE_PROCESS_TAB|wx.TE_PROCESS_ENTER,  
2664 - agwStyle=floatspin.FS_RIGHT)  
2665 - w, h = self.spin_mult.GetTextExtent('M')  
2666 - self.spin_mult.SetMinSize((w*7, -1)) 2562 + self.spin_mult = InvFloatSpinCtrl(self, -1,
  2563 + value=self.config.confid_mult,
  2564 + min_value=1.0, max_value=10.0,
  2565 + increment=0.1, digits=1)
  2566 + # style=wx.TE_PROCESS_TAB|wx.TE_PROCESS_ENTER,
  2567 + # agwStyle=floatspin.FS_RIGHT)
  2568 + self.spin_mult.CalcSizeFromTextSize()
2667 2569
2668 - self.spin_iters = wx.SpinCtrl(self, -1, value='%d' % self.config.confid_iters, min=0, max=100)  
2669 - self.spin_iters.SetMinSize((w*7, -1)) 2570 + self.spin_iters = InvSpinCtrl(self, -1, value=self.config.confid_iters, min_value=0, max_value=100)
  2571 + self.spin_iters.CalcSizeFromTextSize()
2670 2572
2671 sizer = wx.GridBagSizer(5, 5) 2573 sizer = wx.GridBagSizer(5, 5)
2672 2574
@@ -2713,12 +2615,7 @@ class PanelFFillConfidence(wx.Panel): @@ -2713,12 +2615,7 @@ class PanelFFillConfidence(wx.Panel):
2713 2615
2714 class FFillOptionsDialog(wx.Dialog): 2616 class FFillOptionsDialog(wx.Dialog):
2715 def __init__(self, title, config): 2617 def __init__(self, title, config):
2716 - try:  
2717 - pre = wx.PreDialog()  
2718 - pre.Create(wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)  
2719 - self.PostCreate(pre)  
2720 - except AttributeError:  
2721 - wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP) 2618 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)
2722 2619
2723 self.config = config 2620 self.config = config
2724 2621
@@ -2826,12 +2723,7 @@ class FFillOptionsDialog(wx.Dialog): @@ -2826,12 +2723,7 @@ class FFillOptionsDialog(wx.Dialog):
2826 2723
2827 class SelectPartsOptionsDialog(wx.Dialog): 2724 class SelectPartsOptionsDialog(wx.Dialog):
2828 def __init__(self, config): 2725 def __init__(self, config):
2829 - try:  
2830 - pre = wx.PreDialog()  
2831 - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Select mask parts"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)  
2832 - self.PostCreate(pre)  
2833 - except AttributeError:  
2834 - wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, _(u"Select mask parts"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP) 2726 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, _(u"Select mask parts"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)
2835 2727
2836 self.config = config 2728 self.config = config
2837 2729
@@ -2911,12 +2803,7 @@ class SelectPartsOptionsDialog(wx.Dialog): @@ -2911,12 +2803,7 @@ class SelectPartsOptionsDialog(wx.Dialog):
2911 2803
2912 class FFillSegmentationOptionsDialog(wx.Dialog): 2804 class FFillSegmentationOptionsDialog(wx.Dialog):
2913 def __init__(self, config, ID=-1, title=_(u"Region growing"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP): 2805 def __init__(self, config, ID=-1, title=_(u"Region growing"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP):
2914 - try:  
2915 - pre = wx.PreDialog()  
2916 - pre.Create(wx.GetApp().GetTopWindow(), ID, title=title, style=style)  
2917 - self.PostCreate(pre)  
2918 - except AttributeError:  
2919 - wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style) 2806 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style)
2920 2807
2921 self.config = config 2808 self.config = config
2922 2809
@@ -3117,15 +3004,7 @@ class CropOptionsDialog(wx.Dialog): @@ -3117,15 +3004,7 @@ class CropOptionsDialog(wx.Dialog):
3117 3004
3118 def __init__(self, config, ID=-1, title=_(u"Crop mask"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP): 3005 def __init__(self, config, ID=-1, title=_(u"Crop mask"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP):
3119 self.config = config 3006 self.config = config
3120 - try:  
3121 - pre = wx.PreDialog()  
3122 -  
3123 - pre.Create(wx.GetApp().GetTopWindow(), ID, title=title, style=style)  
3124 - self.PostCreate(pre)  
3125 - except AttributeError:  
3126 - wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style)  
3127 -  
3128 - 3007 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style)
3129 self._init_gui() 3008 self._init_gui()
3130 3009
3131 def UpdateValues(self, limits): 3010 def UpdateValues(self, limits):
@@ -3236,13 +3115,7 @@ class CropOptionsDialog(wx.Dialog): @@ -3236,13 +3115,7 @@ class CropOptionsDialog(wx.Dialog):
3236 3115
3237 class FillHolesAutoDialog(wx.Dialog): 3116 class FillHolesAutoDialog(wx.Dialog):
3238 def __init__(self, title): 3117 def __init__(self, title):
3239 - try:  
3240 - pre = wx.PreDialog()  
3241 - pre.Create(wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)  
3242 - self.PostCreate(pre)  
3243 - except AttributeError:  
3244 - wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)  
3245 - 3118 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)
3246 self._init_gui() 3119 self._init_gui()
3247 3120
3248 def _init_gui(self): 3121 def _init_gui(self):
@@ -3251,7 +3124,7 @@ class FillHolesAutoDialog(wx.Dialog): @@ -3251,7 +3124,7 @@ class FillHolesAutoDialog(wx.Dialog):
3251 else: 3124 else:
3252 border_style = wx.SUNKEN_BORDER 3125 border_style = wx.SUNKEN_BORDER
3253 3126
3254 - self.spin_size = wx.SpinCtrl(self, -1, value='1000', min=1, max=1000000000) 3127 + self.spin_size = InvSpinCtrl(self, -1, value=1000, min_value=1, max_value=1000000000)
3255 self.panel_target = PanelTargeFFill(self, style=border_style|wx.TAB_TRAVERSAL) 3128 self.panel_target = PanelTargeFFill(self, style=border_style|wx.TAB_TRAVERSAL)
3256 self.panel2dcon = Panel2DConnectivity(self, show_orientation=True, style=border_style|wx.TAB_TRAVERSAL) 3129 self.panel2dcon = Panel2DConnectivity(self, show_orientation=True, style=border_style|wx.TAB_TRAVERSAL)
3257 self.panel3dcon = Panel3DConnectivity(self, style=border_style|wx.TAB_TRAVERSAL) 3130 self.panel3dcon = Panel3DConnectivity(self, style=border_style|wx.TAB_TRAVERSAL)
@@ -3340,14 +3213,8 @@ class FillHolesAutoDialog(wx.Dialog): @@ -3340,14 +3213,8 @@ class FillHolesAutoDialog(wx.Dialog):
3340 3213
3341 class MaskDensityDialog(wx.Dialog): 3214 class MaskDensityDialog(wx.Dialog):
3342 def __init__(self, title): 3215 def __init__(self, title):
3343 - try:  
3344 - pre = wx.PreDialog()  
3345 - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Mask density"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)  
3346 - self.PostCreate(pre)  
3347 - except AttributeError:  
3348 - wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, _(u"Mask density"),  
3349 - style=wx.DEFAULT_DIALOG_STYLE | wx.FRAME_FLOAT_ON_PARENT)  
3350 - 3216 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, _(u"Mask density"),
  3217 + style=wx.DEFAULT_DIALOG_STYLE | wx.FRAME_FLOAT_ON_PARENT)
3351 self._init_gui() 3218 self._init_gui()
3352 self._bind_events() 3219 self._bind_events()
3353 3220
@@ -3456,14 +3323,8 @@ class ObjectCalibrationDialog(wx.Dialog): @@ -3456,14 +3323,8 @@ class ObjectCalibrationDialog(wx.Dialog):
3456 self.obj_fiducials = np.full([5, 3], np.nan) 3323 self.obj_fiducials = np.full([5, 3], np.nan)
3457 self.obj_orients = np.full([5, 3], np.nan) 3324 self.obj_orients = np.full([5, 3], np.nan)
3458 3325
3459 - try:  
3460 - pre = wx.PreDialog()  
3461 - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Object calibration"), size=(450, 440),  
3462 - style=wx.DEFAULT_DIALOG_STYLE | wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)  
3463 - self.PostCreate(pre)  
3464 - except AttributeError:  
3465 - wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, _(u"Object calibration"), size=(450, 440),  
3466 - style=wx.DEFAULT_DIALOG_STYLE | wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP) 3326 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, _(u"Object calibration"), size=(450, 440),
  3327 + style=wx.DEFAULT_DIALOG_STYLE | wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)
3467 3328
3468 self._init_gui() 3329 self._init_gui()
3469 self.LoadObject() 3330 self.LoadObject()
invesalius/gui/dicom_preview_panel.py
@@ -149,7 +149,7 @@ class DicomPaintPanel(wx.Panel): @@ -149,7 +149,7 @@ class DicomPaintPanel(wx.Panel):
149 self.Bind(wx.EVT_SIZE, self.OnSize) 149 self.Bind(wx.EVT_SIZE, self.OnSize)
150 150
151 def _build_bitmap(self, image): 151 def _build_bitmap(self, image):
152 - bmp = wx.BitmapFromImage(image) 152 + bmp = wx.Bitmap(image)
153 return bmp 153 return bmp
154 154
155 def _image_resize(self, image): 155 def _image_resize(self, image):
invesalius/gui/frame.py
@@ -820,7 +820,7 @@ class MenuBar(wx.MenuBar): @@ -820,7 +820,7 @@ class MenuBar(wx.MenuBar):
820 app = file_menu.Append 820 app = file_menu.Append
821 app(const.ID_DICOM_IMPORT, _("Import DICOM...\tCtrl+I")) 821 app(const.ID_DICOM_IMPORT, _("Import DICOM...\tCtrl+I"))
822 #app(const.ID_DICOM_NETWORK, _("Retrieve DICOM from PACS")) 822 #app(const.ID_DICOM_NETWORK, _("Retrieve DICOM from PACS"))
823 - file_menu.AppendMenu(const.ID_IMPORT_OTHERS_FILES, _("Import other files..."), others_file_menu) 823 + file_menu.Append(const.ID_IMPORT_OTHERS_FILES, _("Import other files..."), others_file_menu)
824 app(const.ID_PROJECT_OPEN, _("Open project...\tCtrl+O")) 824 app(const.ID_PROJECT_OPEN, _("Open project...\tCtrl+O"))
825 app(const.ID_PROJECT_SAVE, _("Save project\tCtrl+S")) 825 app(const.ID_PROJECT_SAVE, _("Save project\tCtrl+S"))
826 app(const.ID_PROJECT_SAVE_AS, _("Save project as...\tCtrl+Shift+S")) 826 app(const.ID_PROJECT_SAVE_AS, _("Save project as...\tCtrl+Shift+S"))
@@ -848,12 +848,12 @@ class MenuBar(wx.MenuBar): @@ -848,12 +848,12 @@ class MenuBar(wx.MenuBar):
848 848
849 file_edit_item_undo = wx.MenuItem(file_edit, wx.ID_UNDO, _("Undo\tCtrl+Z")) 849 file_edit_item_undo = wx.MenuItem(file_edit, wx.ID_UNDO, _("Undo\tCtrl+Z"))
850 file_edit_item_undo.SetBitmap(self.BMP_UNDO) 850 file_edit_item_undo.SetBitmap(self.BMP_UNDO)
851 - file_edit.AppendItem(file_edit_item_undo) 851 + file_edit.Append(file_edit_item_undo)
852 file_edit_item_undo.Enable(False) 852 file_edit_item_undo.Enable(False)
853 853
854 file_edit_item_redo = wx.MenuItem(file_edit, wx.ID_REDO, _("Redo\tCtrl+Y")) 854 file_edit_item_redo = wx.MenuItem(file_edit, wx.ID_REDO, _("Redo\tCtrl+Y"))
855 file_edit_item_redo.SetBitmap(self.BMP_REDO) 855 file_edit_item_redo.SetBitmap(self.BMP_REDO)
856 - file_edit.AppendItem(file_edit_item_redo) 856 + file_edit.Append(file_edit_item_redo)
857 file_edit_item_redo.Enable(False) 857 file_edit_item_redo.Enable(False)
858 else: 858 else:
859 file_edit.Append(wx.ID_UNDO, _("Undo\tCtrl+Z")).Enable(False) 859 file_edit.Append(wx.ID_UNDO, _("Undo\tCtrl+Z")).Enable(False)
@@ -925,17 +925,17 @@ class MenuBar(wx.MenuBar): @@ -925,17 +925,17 @@ class MenuBar(wx.MenuBar):
925 swap_axes_menu.Append(const.ID_SWAP_XZ, _("From Right-Left to Top-Bottom")).Enable(False) 925 swap_axes_menu.Append(const.ID_SWAP_XZ, _("From Right-Left to Top-Bottom")).Enable(False)
926 swap_axes_menu.Append(const.ID_SWAP_YZ, _("From Anterior-Posterior to Top-Bottom")).Enable(False) 926 swap_axes_menu.Append(const.ID_SWAP_YZ, _("From Anterior-Posterior to Top-Bottom")).Enable(False)
927 927
928 - image_menu.AppendMenu(wx.NewId(), _('Flip'), flip_menu)  
929 - image_menu.AppendMenu(wx.NewId(), _('Swap axes'), swap_axes_menu) 928 + image_menu.Append(wx.NewId(), _('Flip'), flip_menu)
  929 + image_menu.Append(wx.NewId(), _('Swap axes'), swap_axes_menu)
930 930
931 mask_density_menu = image_menu.Append(const.ID_MASK_DENSITY_MEASURE, _(u'Mask Density measure')) 931 mask_density_menu = image_menu.Append(const.ID_MASK_DENSITY_MEASURE, _(u'Mask Density measure'))
932 reorient_menu = image_menu.Append(const.ID_REORIENT_IMG, _(u'Reorient image\tCtrl+Shift+R')) 932 reorient_menu = image_menu.Append(const.ID_REORIENT_IMG, _(u'Reorient image\tCtrl+Shift+R'))
933 933
934 reorient_menu.Enable(False) 934 reorient_menu.Enable(False)
935 - tools_menu.AppendMenu(-1, _(u'Image'), image_menu)  
936 - tools_menu.AppendMenu(-1, _(u"Mask"), mask_menu)  
937 - tools_menu.AppendMenu(-1, _(u"Segmentation"), segmentation_menu)  
938 - tools_menu.AppendMenu(-1, _(u"Surface"), surface_menu) 935 + tools_menu.Append(-1, _(u'Image'), image_menu)
  936 + tools_menu.Append(-1, _(u"Mask"), mask_menu)
  937 + tools_menu.Append(-1, _(u"Segmentation"), segmentation_menu)
  938 + tools_menu.Append(-1, _(u"Surface"), surface_menu)
939 939
940 #View 940 #View
941 self.view_menu = view_menu = wx.Menu() 941 self.view_menu = view_menu = wx.Menu()
@@ -961,7 +961,7 @@ class MenuBar(wx.MenuBar): @@ -961,7 +961,7 @@ class MenuBar(wx.MenuBar):
961 961
962 #view_menu = wx.Menu() 962 #view_menu = wx.Menu()
963 #app = view_menu.Append 963 #app = view_menu.Append
964 - #appm = view_menu.AppendMenu 964 + #appm = view_menu.Append
965 #appm(-1, "Toolbars",view_tool_menu) 965 #appm(-1, "Toolbars",view_tool_menu)
966 #appm(-1, "Layout", view_layout_menu) 966 #appm(-1, "Layout", view_layout_menu)
967 #view_menu.AppendSeparator() 967 #view_menu.AppendSeparator()
@@ -2007,8 +2007,8 @@ class HistoryToolBar(AuiToolBar): @@ -2007,8 +2007,8 @@ class HistoryToolBar(AuiToolBar):
2007 Bind normal events from wx (except pubsub related). 2007 Bind normal events from wx (except pubsub related).
2008 """ 2008 """
2009 #self.Bind(wx.EVT_TOOL, self.OnToggle) 2009 #self.Bind(wx.EVT_TOOL, self.OnToggle)
2010 - wx.EVT_TOOL( self, wx.ID_UNDO, self.OnUndo )  
2011 - wx.EVT_TOOL( self, wx.ID_REDO, self.OnRedo ) 2010 + self.Bind(wx.EVT_TOOL, self.OnUndo, id=wx.ID_UNDO)
  2011 + self.Bind(wx.EVT_TOOL, self.OnRedo, id=wx.ID_REDO)
2012 2012
2013 def __init_items(self): 2013 def __init_items(self):
2014 """ 2014 """
invesalius/gui/import_network_panel.py
@@ -675,24 +675,24 @@ class NodesPanel(wx.Panel): @@ -675,24 +675,24 @@ class NodesPanel(wx.Panel):
675 675
676 self.hosts[0] = [True, "localhost", "", "invesalius"] 676 self.hosts[0] = [True, "localhost", "", "invesalius"]
677 try: 677 try:
678 - index = self.tree_node.InsertStringItem(sys.maxsize, "") 678 + index = self.tree_node.InsertItem(sys.maxsize, "")
679 except (OverflowError, AssertionError): 679 except (OverflowError, AssertionError):
680 - index = self.tree_node.InsertStringItem(sys.maxint, "")  
681 - self.tree_node.SetStringItem(index, 1, "localhost")  
682 - self.tree_node.SetStringItem(index, 2, "")  
683 - self.tree_node.SetStringItem(index, 3, "invesalius")  
684 - self.tree_node.SetStringItem(index, 4, "ok") 680 + index = self.tree_node.InsertItem(sys.maxint, "")
  681 + self.tree_node.SetItem(index, 1, "localhost")
  682 + self.tree_node.SetItem(index, 2, "")
  683 + self.tree_node.SetItem(index, 3, "invesalius")
  684 + self.tree_node.SetItem(index, 4, "ok")
685 self.tree_node.CheckItem(index) 685 self.tree_node.CheckItem(index)
686 self.tree_node.SetItemBackgroundColour(index, wx.Colour(245,245,245)) 686 self.tree_node.SetItemBackgroundColour(index, wx.Colour(245,245,245))
687 #print ">>>>>>>>>>>>>>>>>>>>>", sys.maxint 687 #print ">>>>>>>>>>>>>>>>>>>>>", sys.maxint
688 - #index = self.tree_node.InsertStringItem(sys.maxint, "")#adiciona vazio a coluna de check  
689 - #self.tree_node.SetStringItem(index, 1, "200.144.114.19")  
690 - #self.tree_node.SetStringItem(index, 2, "80") 688 + #index = self.tree_node.InsertItem(sys.maxint, "")#adiciona vazio a coluna de check
  689 + #self.tree_node.SetItem(index, 1, "200.144.114.19")
  690 + #self.tree_node.SetItem(index, 2, "80")
691 #self.tree_node.SetItemData(index, 0) 691 #self.tree_node.SetItemData(index, 0)
692 692
693 - #index2 = self.tree_node.InsertStringItem(sys.maxint, "")#adiciona vazio a coluna de check  
694 - #self.tree_node.SetStringItem(index2, 1, "200.144.114.19")  
695 - #self.tree_node.SetStringItem(index2, 2, "80") 693 + #index2 = self.tree_node.InsertItem(sys.maxint, "")#adiciona vazio a coluna de check
  694 + #self.tree_node.SetItem(index2, 1, "200.144.114.19")
  695 + #self.tree_node.SetItem(index2, 2, "80")
696 #self.tree_node.SetItemData(index2, 0) 696 #self.tree_node.SetItemData(index2, 0)
697 697
698 self.btn_add = wx.Button(self, -1, _("Add")) 698 self.btn_add = wx.Button(self, -1, _("Add"))
@@ -732,12 +732,12 @@ class NodesPanel(wx.Panel): @@ -732,12 +732,12 @@ class NodesPanel(wx.Panel):
732 732
733 def OnButtonAdd(self, evt): 733 def OnButtonAdd(self, evt):
734 #adiciona vazio a coluna de check 734 #adiciona vazio a coluna de check
735 - index = self.tree_node.InsertStringItem(sys.maxsize, "") 735 + index = self.tree_node.InsertItem(sys.maxsize, "")
736 736
737 self.hosts[index] = [True, "localhost", "80", ""] 737 self.hosts[index] = [True, "localhost", "80", ""]
738 - self.tree_node.SetStringItem(index, 1, "localhost")  
739 - self.tree_node.SetStringItem(index, 2, "80")  
740 - self.tree_node.SetStringItem(index, 3, "") 738 + self.tree_node.SetItem(index, 1, "localhost")
  739 + self.tree_node.SetItem(index, 2, "80")
  740 + self.tree_node.SetItem(index, 3, "")
741 self.tree_node.CheckItem(index) 741 self.tree_node.CheckItem(index)
742 742
743 def OnLeftDown(self, evt): 743 def OnLeftDown(self, evt):
@@ -770,9 +770,9 @@ class NodesPanel(wx.Panel): @@ -770,9 +770,9 @@ class NodesPanel(wx.Panel):
770 dn.SetAETitle(self.hosts[0][3]) 770 dn.SetAETitle(self.hosts[0][3])
771 771
772 if dn.RunCEcho(): 772 if dn.RunCEcho():
773 - self.tree_node.SetStringItem(key, 4, _("ok")) 773 + self.tree_node.SetItem(key, 4, _("ok"))
774 else: 774 else:
775 - self.tree_node.SetStringItem(key, 4, _("error")) 775 + self.tree_node.SetItem(key, 4, _("error"))
776 776
777 def RightButton(self,evt): 777 def RightButton(self,evt):
778 event.Skip() 778 event.Skip()
invesalius/gui/preferences.py
@@ -17,15 +17,8 @@ class Preferences(wx.Dialog): @@ -17,15 +17,8 @@ class Preferences(wx.Dialog):
17 def __init__( self, parent, id = ID, title = _("Preferences"), size=wx.DefaultSize,\ 17 def __init__( self, parent, id = ID, title = _("Preferences"), size=wx.DefaultSize,\
18 pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER): 18 pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
19 19
20 - try:  
21 - pre = wx.PreDialog()  
22 - pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)  
23 - pre.Create(parent, ID, title, pos, size, style)  
24 -  
25 - self.PostCreate(pre)  
26 - except AttributeError:  
27 - wx.Dialog.__init__(self, parent, ID, title, pos, size, style)  
28 - self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP) 20 + wx.Dialog.__init__(self, parent, ID, title, pos, size, style)
  21 + self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
29 22
30 sizer = wx.BoxSizer(wx.VERTICAL) 23 sizer = wx.BoxSizer(wx.VERTICAL)
31 24
invesalius/gui/task_exporter.py
@@ -257,7 +257,7 @@ class InnerTaskPanel(wx.Panel): @@ -257,7 +257,7 @@ class InnerTaskPanel(wx.Panel):
257 257
258 for id in self.id_to_name: 258 for id in self.id_to_name:
259 item = wx.MenuItem(menu, id, self.id_to_name[id]) 259 item = wx.MenuItem(menu, id, self.id_to_name[id])
260 - menu.AppendItem(item) 260 + menu.Append(item)
261 261
262 self.menu_picture = menu 262 self.menu_picture = menu
263 menu.Bind(wx.EVT_MENU, self.OnMenuPicture) 263 menu.Bind(wx.EVT_MENU, self.OnMenuPicture)
invesalius/gui/task_navigator.py
@@ -1093,7 +1093,7 @@ class MarkersPanel(wx.Panel): @@ -1093,7 +1093,7 @@ class MarkersPanel(wx.Panel):
1093 if id_label == 'TARGET': 1093 if id_label == 'TARGET':
1094 id_label = '' 1094 id_label = ''
1095 dlg.InvalidTargetID() 1095 dlg.InvalidTargetID()
1096 - self.lc.SetStringItem(list_index, 4, id_label) 1096 + self.lc.SetItem(list_index, 4, id_label)
1097 # Add the new ID to exported list 1097 # Add the new ID to exported list
1098 if len(self.list_coord[list_index]) > 8: 1098 if len(self.list_coord[list_index]) > 8:
1099 self.list_coord[list_index][10] = str(id_label) 1099 self.list_coord[list_index][10] = str(id_label)
@@ -1107,7 +1107,7 @@ class MarkersPanel(wx.Panel): @@ -1107,7 +1107,7 @@ class MarkersPanel(wx.Panel):
1107 if self.tgt_flag: 1107 if self.tgt_flag:
1108 self.lc.SetItemBackgroundColour(self.tgt_index, 'white') 1108 self.lc.SetItemBackgroundColour(self.tgt_index, 'white')
1109 Publisher.sendMessage('Set target transparency', status=False, index=self.tgt_index) 1109 Publisher.sendMessage('Set target transparency', status=False, index=self.tgt_index)
1110 - self.lc.SetStringItem(self.tgt_index, 4, '') 1110 + self.lc.SetItem(self.tgt_index, 4, '')
1111 # Add the new ID to exported list 1111 # Add the new ID to exported list
1112 if len(self.list_coord[self.tgt_index]) > 8: 1112 if len(self.list_coord[self.tgt_index]) > 8:
1113 self.list_coord[self.tgt_index][10] = str('') 1113 self.list_coord[self.tgt_index][10] = str('')
@@ -1197,7 +1197,7 @@ class MarkersPanel(wx.Panel): @@ -1197,7 +1197,7 @@ class MarkersPanel(wx.Panel):
1197 del self.list_coord[i] 1197 del self.list_coord[i]
1198 self.lc.DeleteItem(i) 1198 self.lc.DeleteItem(i)
1199 for n in range(0, self.lc.GetItemCount()): 1199 for n in range(0, self.lc.GetItemCount()):
1200 - self.lc.SetStringItem(n, 0, str(n+1)) 1200 + self.lc.SetItem(n, 0, str(n+1))
1201 self.marker_ind -= 1 1201 self.marker_ind -= 1
1202 Publisher.sendMessage('Remove marker', index=index) 1202 Publisher.sendMessage('Remove marker', index=index)
1203 1203
@@ -1312,11 +1312,11 @@ class MarkersPanel(wx.Panel): @@ -1312,11 +1312,11 @@ class MarkersPanel(wx.Panel):
1312 1312
1313 # Add item to list control in panel 1313 # Add item to list control in panel
1314 num_items = self.lc.GetItemCount() 1314 num_items = self.lc.GetItemCount()
1315 - self.lc.InsertStringItem(num_items, str(num_items + 1))  
1316 - self.lc.SetStringItem(num_items, 1, str(round(coord[0], 2)))  
1317 - self.lc.SetStringItem(num_items, 2, str(round(coord[1], 2)))  
1318 - self.lc.SetStringItem(num_items, 3, str(round(coord[2], 2)))  
1319 - self.lc.SetStringItem(num_items, 4, str(marker_id)) 1315 + self.lc.InsertItem(num_items, str(num_items + 1))
  1316 + self.lc.SetItem(num_items, 1, str(round(coord[0], 2)))
  1317 + self.lc.SetItem(num_items, 2, str(round(coord[1], 2)))
  1318 + self.lc.SetItem(num_items, 3, str(round(coord[2], 2)))
  1319 + self.lc.SetItem(num_items, 4, str(marker_id))
1320 self.lc.EnsureVisible(num_items) 1320 self.lc.EnsureVisible(num_items)
1321 1321
1322 def GetSelectedItems(self): 1322 def GetSelectedItems(self):
invesalius/gui/task_slice.py
@@ -38,6 +38,7 @@ import invesalius.data.slice_ as slice_ @@ -38,6 +38,7 @@ import invesalius.data.slice_ as slice_
38 import invesalius.constants as const 38 import invesalius.constants as const
39 import invesalius.gui.dialogs as dlg 39 import invesalius.gui.dialogs as dlg
40 import invesalius.gui.widgets.gradient as grad 40 import invesalius.gui.widgets.gradient as grad
  41 +from invesalius.gui.widgets.inv_spinctrl import InvSpinCtrl
41 42
42 from invesalius.project import Project 43 from invesalius.project import Project
43 import invesalius.session as ses 44 import invesalius.session as ses
@@ -693,8 +694,8 @@ class EditionTools(wx.Panel): @@ -693,8 +694,8 @@ class EditionTools(wx.Panel):
693 item2 = wx.MenuItem(menu, MENU_BRUSH_SQUARE, _("Square")) 694 item2 = wx.MenuItem(menu, MENU_BRUSH_SQUARE, _("Square"))
694 item2.SetBitmap(SQUARE_BMP) 695 item2.SetBitmap(SQUARE_BMP)
695 696
696 - menu.AppendItem(item)  
697 - menu.AppendItem(item2) 697 + menu.Append(item)
  698 + menu.Append(item2)
698 699
699 bmp_brush_format = {const.BRUSH_CIRCLE: CIRCLE_BMP, 700 bmp_brush_format = {const.BRUSH_CIRCLE: CIRCLE_BMP,
700 const.BRUSH_SQUARE: SQUARE_BMP} 701 const.BRUSH_SQUARE: SQUARE_BMP}
@@ -705,14 +706,9 @@ class EditionTools(wx.Panel): @@ -705,14 +706,9 @@ class EditionTools(wx.Panel):
705 btn_brush_format.SetMenu(menu) 706 btn_brush_format.SetMenu(menu)
706 self.btn_brush_format = btn_brush_format 707 self.btn_brush_format = btn_brush_format
707 708
  709 + spin_brush_size = InvSpinCtrl(self, -1, value=const.BRUSH_SIZE, min_value=1, max_value=1000, spin_button=False)
708 # To calculate best width to spinctrl 710 # To calculate best width to spinctrl
709 - dc = wx.WindowDC(self)  
710 - dc.SetFont(self.GetFont())  
711 - width, height = dc.GetTextExtent("MMM")  
712 -  
713 - spin_brush_size = wx.SpinCtrl(self, -1, "", size=(width + 20, -1))  
714 - spin_brush_size.SetRange(1,100)  
715 - spin_brush_size.SetValue(const.BRUSH_SIZE) 711 + spin_brush_size.CalcSizeFromTextSize("MMMM")
716 spin_brush_size.Bind(wx.EVT_SPINCTRL, self.OnBrushSize) 712 spin_brush_size.Bind(wx.EVT_SPINCTRL, self.OnBrushSize)
717 self.spin = spin_brush_size 713 self.spin = spin_brush_size
718 714
@@ -861,8 +857,8 @@ class WatershedTool(EditionTools): @@ -861,8 +857,8 @@ class WatershedTool(EditionTools):
861 item2 = wx.MenuItem(menu, MENU_BRUSH_SQUARE, _("Square")) 857 item2 = wx.MenuItem(menu, MENU_BRUSH_SQUARE, _("Square"))
862 item2.SetBitmap(SQUARE_BMP) 858 item2.SetBitmap(SQUARE_BMP)
863 859
864 - menu.AppendItem(item)  
865 - menu.AppendItem(item2) 860 + menu.Append(item)
  861 + menu.Append(item2)
866 862
867 bmp_brush_format = {const.BRUSH_CIRCLE: CIRCLE_BMP, 863 bmp_brush_format = {const.BRUSH_CIRCLE: CIRCLE_BMP,
868 const.BRUSH_SQUARE: SQUARE_BMP} 864 const.BRUSH_SQUARE: SQUARE_BMP}
@@ -873,14 +869,9 @@ class WatershedTool(EditionTools): @@ -873,14 +869,9 @@ class WatershedTool(EditionTools):
873 btn_brush_format.SetMenu(menu) 869 btn_brush_format.SetMenu(menu)
874 self.btn_brush_format = btn_brush_format 870 self.btn_brush_format = btn_brush_format
875 871
  872 + spin_brush_size = InvSpinCtrl(self, -1, value=const.BRUSH_SIZE, min_value=1, max_value=1000, spin_button=False)
876 # To calculate best width to spinctrl 873 # To calculate best width to spinctrl
877 - dc = wx.WindowDC(self)  
878 - dc.SetFont(self.GetFont())  
879 - width, height = dc.GetTextExtent("MMM")  
880 -  
881 - spin_brush_size = wx.SpinCtrl(self, -1, "", size=(width + 20, -1))  
882 - spin_brush_size.SetRange(1,100)  
883 - spin_brush_size.SetValue(const.BRUSH_SIZE) 874 + spin_brush_size.CalcSizeFromTextSize("MMMM")
884 spin_brush_size.Bind(wx.EVT_SPINCTRL, self.OnBrushSize) 875 spin_brush_size.Bind(wx.EVT_SPINCTRL, self.OnBrushSize)
885 self.spin = spin_brush_size 876 self.spin = spin_brush_size
886 877
invesalius/gui/task_surface.py
@@ -38,6 +38,8 @@ import wx.lib.platebtn as pbtn @@ -38,6 +38,8 @@ import wx.lib.platebtn as pbtn
38 import invesalius.project as prj 38 import invesalius.project as prj
39 import invesalius.utils as utl 39 import invesalius.utils as utl
40 40
  41 +from invesalius.gui.widgets.inv_spinctrl import InvSpinCtrl, InvFloatSpinCtrl
  42 +
41 #INTERPOLATION_MODE_LIST = ["Cubic", "Linear", "NearestNeighbor"] 43 #INTERPOLATION_MODE_LIST = ["Cubic", "Linear", "NearestNeighbor"]
42 MIN_TRANSPARENCY = 0 44 MIN_TRANSPARENCY = 0
43 MAX_TRANSPARENCY = 100 45 MAX_TRANSPARENCY = 100
@@ -620,9 +622,7 @@ class QualityAdjustment(wx.Panel): @@ -620,9 +622,7 @@ class QualityAdjustment(wx.Panel):
620 622
621 text_decimate = wx.StaticText(self, -1, _("Decimate resolution:")) 623 text_decimate = wx.StaticText(self, -1, _("Decimate resolution:"))
622 624
623 - spin_decimate = wx.SpinCtrl(self, -1, "", (30, 50))  
624 - spin_decimate.SetRange(1,100)  
625 - spin_decimate.SetValue(30) 625 + spin_decimate = InvSpinCtrl(self, -1, value=30, min_value=1, max_value=100, size=(30, 50))
626 #spin_decimate.Bind(wx.EVT_TEXT, self.OnDecimate) 626 #spin_decimate.Bind(wx.EVT_TEXT, self.OnDecimate)
627 627
628 # LINE 3 628 # LINE 3
@@ -630,9 +630,7 @@ class QualityAdjustment(wx.Panel): @@ -630,9 +630,7 @@ class QualityAdjustment(wx.Panel):
630 630
631 text_smooth = wx.StaticText(self, -1, _("Smooth iterations:")) 631 text_smooth = wx.StaticText(self, -1, _("Smooth iterations:"))
632 632
633 - spin_smooth = wx.SpinCtrl(self, -1, "", (30, 50))  
634 - spin_smooth.SetRange(1,100)  
635 - spin_smooth.SetValue(0) 633 + spin_smooth = InvSpinCtrl(self, -1, value=0, min_value=1, max_values=100, size=(30, 50))
636 634
637 # MIXED LINE 2 AND 3 635 # MIXED LINE 2 AND 3
638 flag_link = wx.EXPAND|wx.GROW|wx.RIGHT|wx.LEFT 636 flag_link = wx.EXPAND|wx.GROW|wx.RIGHT|wx.LEFT
invesalius/gui/widgets/canvas_renderer.py
@@ -140,7 +140,7 @@ class CanvasRendererCTX: @@ -140,7 +140,7 @@ class CanvasRendererCTX:
140 self.rgb = np.zeros((h, w, 3), dtype=np.uint8) 140 self.rgb = np.zeros((h, w, 3), dtype=np.uint8)
141 self.alpha = np.zeros((h, w, 1), dtype=np.uint8) 141 self.alpha = np.zeros((h, w, 1), dtype=np.uint8)
142 142
143 - self.bitmap = wx.EmptyBitmapRGBA(w, h) 143 + self.bitmap = wx.Bitmap.FromRGBA(w, h)
144 try: 144 try:
145 self.image = wx.Image(w, h, self.rgb, self.alpha) 145 self.image = wx.Image(w, h, self.rgb, self.alpha)
146 except TypeError: 146 except TypeError:
@@ -155,7 +155,7 @@ class CanvasRendererCTX: @@ -155,7 +155,7 @@ class CanvasRendererCTX:
155 self.rgb = np.zeros((h, w, 3), dtype=np.uint8) 155 self.rgb = np.zeros((h, w, 3), dtype=np.uint8)
156 self.alpha = np.zeros((h, w, 1), dtype=np.uint8) 156 self.alpha = np.zeros((h, w, 1), dtype=np.uint8)
157 157
158 - self.bitmap = wx.EmptyBitmapRGBA(w, h) 158 + self.bitmap = wx.Bitmap.FromRGBA(w, h)
159 try: 159 try:
160 self.image = wx.Image(w, h, self.rgb, self.alpha) 160 self.image = wx.Image(w, h, self.rgb, self.alpha)
161 except TypeError: 161 except TypeError:
@@ -379,7 +379,7 @@ class CanvasRendererCTX: @@ -379,7 +379,7 @@ class CanvasRendererCTX:
379 if size is None: 379 if size is None:
380 size = self.canvas_renderer.GetSize() 380 size = self.canvas_renderer.GetSize()
381 w, h = size 381 w, h = size
382 - image = wx.EmptyImage(w, h) 382 + image = wx.Image(w, h)
383 image.Clear() 383 image.Clear()
384 384
385 arr = np.zeros((h, w, 4), dtype=np.uint8) 385 arr = np.zeros((h, w, 4), dtype=np.uint8)
invesalius/gui/widgets/clut_raycasting.py
@@ -383,7 +383,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -383,7 +383,7 @@ class CLUTRaycastingWidget(wx.Panel):
383 self.to_render = True 383 self.to_render = True
384 i,j = self.point_dragged 384 i,j = self.point_dragged
385 385
386 - width, height= self.GetVirtualSizeTuple() 386 + width, height= self.GetVirtualSize()
387 387
388 if y >= height - self.padding: 388 if y >= height - self.padding:
389 y = height - self.padding 389 y = height - self.padding
@@ -525,7 +525,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -525,7 +525,7 @@ class CLUTRaycastingWidget(wx.Panel):
525 x,y = node.x, node.y 525 x,y = node.x, node.y
526 value = node.graylevel 526 value = node.graylevel
527 alpha = node.opacity 527 alpha = node.opacity
528 - widget_width, widget_height = self.GetVirtualSizeTuple() 528 + widget_width, widget_height = self.GetVirtualSize()
529 529
530 font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) 530 font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
531 font.SetWeight(wx.BOLD) 531 font.SetWeight(wx.BOLD)
@@ -600,7 +600,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -600,7 +600,7 @@ class CLUTRaycastingWidget(wx.Panel):
600 600
601 def Render(self, dc): 601 def Render(self, dc):
602 ctx = wx.GraphicsContext.Create(dc) 602 ctx = wx.GraphicsContext.Create(dc)
603 - width, height= self.GetVirtualSizeTuple() 603 + width, height= self.GetVirtualSize()
604 height -= (self.padding * 2) 604 height -= (self.padding * 2)
605 width -= self.padding 605 width -= self.padding
606 606
@@ -614,7 +614,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -614,7 +614,7 @@ class CLUTRaycastingWidget(wx.Panel):
614 self._draw_selected_point_text(ctx) 614 self._draw_selected_point_text(ctx)
615 615
616 def _build_histogram(self): 616 def _build_histogram(self):
617 - width, height = self.GetVirtualSizeTuple() 617 + width, height = self.GetVirtualSize()
618 width -= self.padding 618 width -= self.padding
619 height -= (self.padding * 2) 619 height -= (self.padding * 2)
620 x_init = self.Histogram.init 620 x_init = self.Histogram.init
@@ -638,7 +638,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -638,7 +638,7 @@ class CLUTRaycastingWidget(wx.Panel):
638 width = img.GetWidth() 638 width = img.GetWidth()
639 height = img.GetHeight() 639 height = img.GetHeight()
640 self.save_button = Button() 640 self.save_button = Button()
641 - self.save_button.image = wx.BitmapFromImage(img) 641 + self.save_button.image = wx.Bitmap(img)
642 self.save_button.size = (width, height) 642 self.save_button.size = (width, height)
643 643
644 def __sort_pixel_points(self): 644 def __sort_pixel_points(self):
@@ -684,7 +684,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -684,7 +684,7 @@ class CLUTRaycastingWidget(wx.Panel):
684 """ 684 """
685 Given a Hounsfield point returns a pixel point in the canvas. 685 Given a Hounsfield point returns a pixel point in the canvas.
686 """ 686 """
687 - width,height = self.GetVirtualSizeTuple() 687 + width,height = self.GetVirtualSize()
688 width -= (TOOLBAR_SIZE) 688 width -= (TOOLBAR_SIZE)
689 proportion = width * 1.0 / (self.end - self.init) 689 proportion = width * 1.0 / (self.end - self.init)
690 x = (graylevel - self.init) * proportion + TOOLBAR_SIZE 690 x = (graylevel - self.init) * proportion + TOOLBAR_SIZE
@@ -694,7 +694,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -694,7 +694,7 @@ class CLUTRaycastingWidget(wx.Panel):
694 """ 694 """
695 Given a Opacity point returns a pixel point in the canvas. 695 Given a Opacity point returns a pixel point in the canvas.
696 """ 696 """
697 - width,height = self.GetVirtualSizeTuple() 697 + width,height = self.GetVirtualSize()
698 height -= (self.padding * 2) 698 height -= (self.padding * 2)
699 y = height - (opacity * height) + self.padding 699 y = height - (opacity * height) + self.padding
700 return y 700 return y
@@ -703,7 +703,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -703,7 +703,7 @@ class CLUTRaycastingWidget(wx.Panel):
703 """ 703 """
704 Translate from pixel point to Hounsfield scale. 704 Translate from pixel point to Hounsfield scale.
705 """ 705 """
706 - width, height= self.GetVirtualSizeTuple() 706 + width, height= self.GetVirtualSize()
707 width -= (TOOLBAR_SIZE) 707 width -= (TOOLBAR_SIZE)
708 proportion = width * 1.0 / (self.end - self.init) 708 proportion = width * 1.0 / (self.end - self.init)
709 graylevel = (x - TOOLBAR_SIZE) / proportion - abs(self.init) 709 graylevel = (x - TOOLBAR_SIZE) / proportion - abs(self.init)
@@ -713,7 +713,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -713,7 +713,7 @@ class CLUTRaycastingWidget(wx.Panel):
713 """ 713 """
714 Translate from pixel point to opacity. 714 Translate from pixel point to opacity.
715 """ 715 """
716 - width, height= self.GetVirtualSizeTuple() 716 + width, height= self.GetVirtualSize()
717 height -= (self.padding * 2) 717 height -= (self.padding * 2)
718 opacity = (height - y + self.padding) * 1.0 / height 718 opacity = (height - y + self.padding) * 1.0 / height
719 return opacity 719 return opacity
invesalius/gui/widgets/gradient.py
1 # -*- coding: UTF-8 -*- 1 # -*- coding: UTF-8 -*-
2 2
3 -#-------------------------------------------------------------------------- 3 +# --------------------------------------------------------------------------
4 # Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas 4 # Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas
5 # Copyright: (C) 2001 Centro de Pesquisas Renato Archer 5 # Copyright: (C) 2001 Centro de Pesquisas Renato Archer
6 # Homepage: http://www.softwarepublico.gov.br 6 # Homepage: http://www.softwarepublico.gov.br
7 # Contact: invesalius@cti.gov.br 7 # Contact: invesalius@cti.gov.br
8 # License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt) 8 # License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt)
9 -#-------------------------------------------------------------------------- 9 +# --------------------------------------------------------------------------
10 # Este programa e software livre; voce pode redistribui-lo e/ou 10 # Este programa e software livre; voce pode redistribui-lo e/ou
11 # modifica-lo sob os termos da Licenca Publica Geral GNU, conforme 11 # modifica-lo sob os termos da Licenca Publica Geral GNU, conforme
12 # publicada pela Free Software Foundation; de acordo com a versao 2 12 # publicada pela Free Software Foundation; de acordo com a versao 2
@@ -17,14 +17,15 @@ @@ -17,14 +17,15 @@
17 # COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM 17 # COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM
18 # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais 18 # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais
19 # detalhes. 19 # detalhes.
20 -#-------------------------------------------------------------------------- 20 +# --------------------------------------------------------------------------
21 import sys 21 import sys
22 22
23 import numpy 23 import numpy
24 import wx 24 import wx
25 -  
26 from wx.lib import intctrl 25 from wx.lib import intctrl
27 26
  27 +from invesalius.gui.widgets.inv_spinctrl import InvSpinCtrl
  28 +
28 PUSH_WIDTH = 7 29 PUSH_WIDTH = 7
29 30
30 myEVT_SLIDER_CHANGED = wx.NewEventType() 31 myEVT_SLIDER_CHANGED = wx.NewEventType()
@@ -39,14 +40,16 @@ EVT_THRESHOLD_CHANGED = wx.PyEventBinder(myEVT_THRESHOLD_CHANGED, 1) @@ -39,14 +40,16 @@ EVT_THRESHOLD_CHANGED = wx.PyEventBinder(myEVT_THRESHOLD_CHANGED, 1)
39 myEVT_THRESHOLD_CHANGING = wx.NewEventType() 40 myEVT_THRESHOLD_CHANGING = wx.NewEventType()
40 EVT_THRESHOLD_CHANGING = wx.PyEventBinder(myEVT_THRESHOLD_CHANGING, 1) 41 EVT_THRESHOLD_CHANGING = wx.PyEventBinder(myEVT_THRESHOLD_CHANGING, 1)
41 42
  43 +
42 class SliderEvent(wx.PyCommandEvent): 44 class SliderEvent(wx.PyCommandEvent):
43 - def __init__(self , evtType, id, minRange, maxRange, minValue, maxValue):  
44 - wx.PyCommandEvent.__init__(self, evtType, id,) 45 + def __init__(self, evtType, id, minRange, maxRange, minValue, maxValue):
  46 + wx.PyCommandEvent.__init__(self, evtType, id)
45 self.min_range = minRange 47 self.min_range = minRange
46 self.max_range = maxRange 48 self.max_range = maxRange
47 self.minimun = minValue 49 self.minimun = minValue
48 self.maximun = maxValue 50 self.maximun = maxValue
49 51
  52 +
50 class GradientSlider(wx.Panel): 53 class GradientSlider(wx.Panel):
51 # This widget is formed by a gradient background (black-white), two push 54 # This widget is formed by a gradient background (black-white), two push
52 # buttons change the min and max values respectively and a slider which you can drag to 55 # buttons change the min and max values respectively and a slider which you can drag to
@@ -57,7 +60,7 @@ class GradientSlider(wx.Panel): @@ -57,7 +60,7 @@ class GradientSlider(wx.Panel):
57 # minValue: the least value in the range 60 # minValue: the least value in the range
58 # maxValue: the most value in the range 61 # maxValue: the most value in the range
59 # colour: colour used in this widget. 62 # colour: colour used in this widget.
60 - super(GradientSlider, self).__init__(parent, id, size = (100, 25)) 63 + super(GradientSlider, self).__init__(parent, id)
61 self._bind_events_wx() 64 self._bind_events_wx()
62 65
63 self.min_range = minRange 66 self.min_range = minRange
@@ -75,24 +78,50 @@ class GradientSlider(wx.Panel): @@ -75,24 +78,50 @@ class GradientSlider(wx.Panel):
75 self.Bind(wx.EVT_PAINT, self.OnPaint) 78 self.Bind(wx.EVT_PAINT, self.OnPaint)
76 self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackGround) 79 self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackGround)
77 80
78 - if sys.platform == 'win32': 81 + if sys.platform == "win32":
79 self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow) 82 self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow)
80 83
81 self.Bind(wx.EVT_MOTION, self.OnMotion) 84 self.Bind(wx.EVT_MOTION, self.OnMotion)
82 self.Bind(wx.EVT_SIZE, self.OnSize) 85 self.Bind(wx.EVT_SIZE, self.OnSize)
83 86
84 def OnLeaveWindow(self, evt): 87 def OnLeaveWindow(self, evt):
  88 + if self.selected == 0:
  89 + return
  90 +
  91 + x = evt.GetX()
  92 + w, h = self.GetSize()
  93 +
  94 + if self.selected == 1:
  95 + if x - PUSH_WIDTH < 0:
  96 + x = PUSH_WIDTH
  97 + elif x >= self.max_position:
  98 + x = self.max_position
  99 + value = self._min_position_to_minimun(x)
  100 + self.minimun = value
  101 + self.min_position = x
  102 +
  103 + # The user is moving the second push (Max)
  104 + elif self.selected == 2:
  105 + if x + PUSH_WIDTH > w:
  106 + x = w - PUSH_WIDTH
  107 + elif x < self.min_position:
  108 + x = self.min_position
  109 +
  110 + value = self._max_position_to_maximun(x)
  111 + self.maximun = value
  112 + self.max_position = x
  113 +
85 self.selected = 0 114 self.selected = 0
  115 + self._generate_event(myEVT_SLIDER_CHANGED)
86 evt.Skip() 116 evt.Skip()
87 117
88 -  
89 def OnPaint(self, evt): 118 def OnPaint(self, evt):
90 # Where the magic happens. Here the controls are drawn. 119 # Where the magic happens. Here the controls are drawn.
91 dc = wx.BufferedPaintDC(self) 120 dc = wx.BufferedPaintDC(self)
92 dc.Clear() 121 dc.Clear()
93 - 122 +
94 w, h = self.GetSize() 123 w, h = self.GetSize()
95 - width_gradient = w - 2*PUSH_WIDTH 124 + width_gradient = w - 2 * PUSH_WIDTH
96 height_gradient = h 125 height_gradient = h
97 x_init_gradient = PUSH_WIDTH 126 x_init_gradient = PUSH_WIDTH
98 y_init_gradient = 0 127 y_init_gradient = 0
@@ -117,9 +146,11 @@ class GradientSlider(wx.Panel): @@ -117,9 +146,11 @@ class GradientSlider(wx.Panel):
117 dc.DrawRectangle(x_init_gradient + width_gradient, 0, PUSH_WIDTH, h) 146 dc.DrawRectangle(x_init_gradient + width_gradient, 0, PUSH_WIDTH, h)
118 147
119 # Drawing the gradient. 148 # Drawing the gradient.
120 - dc.GradientFillLinear((x_init_gradient, y_init_gradient,  
121 - width_gradient, height_gradient),  
122 - (0, 0, 0), (255,255, 255)) 149 + dc.GradientFillLinear(
  150 + (x_init_gradient, y_init_gradient, width_gradient, height_gradient),
  151 + (0, 0, 0),
  152 + (255, 255, 255),
  153 + )
123 154
124 try: 155 try:
125 n = wx.RendererNative.Get() 156 n = wx.RendererNative.Get()
@@ -131,9 +162,9 @@ class GradientSlider(wx.Panel): @@ -131,9 +162,9 @@ class GradientSlider(wx.Panel):
131 n.DrawPushButton(self, dc, (x_init_push2, 0, PUSH_WIDTH, h)) 162 n.DrawPushButton(self, dc, (x_init_push2, 0, PUSH_WIDTH, h))
132 163
133 # Drawing the transparent slider. 164 # Drawing the transparent slider.
134 - bytes = numpy.array(self.colour * width_transparency * h, 'B') 165 + bytes = numpy.array(self.colour * width_transparency * h, "B")
135 try: 166 try:
136 - slider = wx.BitmapFromBufferRGBA(width_transparency, h, bytes) 167 + slider = wx.Bitmap.FromBufferRGBA(width_transparency, h, bytes)
137 except: 168 except:
138 pass 169 pass
139 else: 170 else:
@@ -151,7 +182,7 @@ class GradientSlider(wx.Panel): @@ -151,7 +182,7 @@ class GradientSlider(wx.Panel):
151 if not self.selected: 182 if not self.selected:
152 # The user is over a push button, change the cursor. 183 # The user is over a push button, change the cursor.
153 if self._is_over_what(x) in (1, 2): 184 if self._is_over_what(x) in (1, 2):
154 - self.SetCursor(wx.StockCursor(wx.CURSOR_SIZEWE)) 185 + self.SetCursor(wx.Cursor(wx.CURSOR_SIZEWE))
155 else: 186 else:
156 self.SetCursor(wx.NullCursor) 187 self.SetCursor(wx.NullCursor)
157 188
@@ -168,7 +199,7 @@ class GradientSlider(wx.Panel): @@ -168,7 +199,7 @@ class GradientSlider(wx.Panel):
168 self.min_position = x 199 self.min_position = x
169 self._generate_event(myEVT_SLIDER_CHANGING) 200 self._generate_event(myEVT_SLIDER_CHANGING)
170 self.Refresh() 201 self.Refresh()
171 - 202 +
172 # The user is moving the second push (Max) 203 # The user is moving the second push (Max)
173 elif self.selected == 2: 204 elif self.selected == 2:
174 x -= self._delta 205 x -= self._delta
@@ -188,13 +219,13 @@ class GradientSlider(wx.Panel): @@ -188,13 +219,13 @@ class GradientSlider(wx.Panel):
188 x -= self._delta 219 x -= self._delta
189 slider_size = self.max_position - self.min_position 220 slider_size = self.max_position - self.min_position
190 diff_values = self.maximun - self.minimun 221 diff_values = self.maximun - self.minimun
191 - 222 +
192 if x - PUSH_WIDTH < 0: 223 if x - PUSH_WIDTH < 0:
193 min_x = PUSH_WIDTH 224 min_x = PUSH_WIDTH
194 self.minimun = self._min_position_to_minimun(min_x) 225 self.minimun = self._min_position_to_minimun(min_x)
195 self.maximun = self.minimun + diff_values 226 self.maximun = self.minimun + diff_values
196 self.CalculateControlPositions() 227 self.CalculateControlPositions()
197 - 228 +
198 elif x + slider_size + PUSH_WIDTH > w: 229 elif x + slider_size + PUSH_WIDTH > w:
199 max_x = w - PUSH_WIDTH 230 max_x = w - PUSH_WIDTH
200 self.maximun = self._max_position_to_maximun(max_x) 231 self.maximun = self._max_position_to_maximun(max_x)
@@ -211,7 +242,6 @@ class GradientSlider(wx.Panel): @@ -211,7 +242,6 @@ class GradientSlider(wx.Panel):
211 self.Refresh() 242 self.Refresh()
212 evt.Skip() 243 evt.Skip()
213 244
214 -  
215 def OnClick(self, evt): 245 def OnClick(self, evt):
216 x = evt.GetX() 246 x = evt.GetX()
217 self.selected = self._is_over_what(x) 247 self.selected = self._is_over_what(x)
@@ -240,34 +270,34 @@ class GradientSlider(wx.Panel): @@ -240,34 +270,34 @@ class GradientSlider(wx.Panel):
240 widget. 270 widget.
241 """ 271 """
242 w, h = self.GetSize() 272 w, h = self.GetSize()
243 - window_width = w - 2*PUSH_WIDTH 273 + window_width = w - 2 * PUSH_WIDTH
244 proportion = window_width / float(self.max_range - self.min_range) 274 proportion = window_width / float(self.max_range - self.min_range)
245 275
246 - self.min_position = int(round((self.minimun - self.min_range) * \  
247 - proportion)) + PUSH_WIDTH  
248 - self.max_position = int(round((self.maximun - self.min_range) * \  
249 - proportion)) + PUSH_WIDTH 276 + self.min_position = (
  277 + int(round((self.minimun - self.min_range) * proportion)) + PUSH_WIDTH
  278 + )
  279 + self.max_position = (
  280 + int(round((self.maximun - self.min_range) * proportion)) + PUSH_WIDTH
  281 + )
250 282
251 def _max_position_to_maximun(self, max_position): 283 def _max_position_to_maximun(self, max_position):
252 - """ 284 + """
253 Calculates the min and max value based on the control positions. 285 Calculates the min and max value based on the control positions.
254 """ 286 """
255 w, h = self.GetSize() 287 w, h = self.GetSize()
256 - window_width = w - 2*PUSH_WIDTH 288 + window_width = w - 2 * PUSH_WIDTH
257 proportion = window_width / float(self.max_range - self.min_range) 289 proportion = window_width / float(self.max_range - self.min_range)
258 290
259 - maximun = int(round((max_position - PUSH_WIDTH)/proportion + \  
260 - self.min_range)) 291 + maximun = int(round((max_position - PUSH_WIDTH) / proportion + self.min_range))
261 292
262 return maximun 293 return maximun
263 294
264 def _min_position_to_minimun(self, min_position): 295 def _min_position_to_minimun(self, min_position):
265 w, h = self.GetSize() 296 w, h = self.GetSize()
266 - window_width = w - 2*PUSH_WIDTH 297 + window_width = w - 2 * PUSH_WIDTH
267 proportion = window_width / float(self.max_range - self.min_range) 298 proportion = window_width / float(self.max_range - self.min_range)
268 299
269 - minimun = int(round((min_position - PUSH_WIDTH)/proportion + \  
270 - self.min_range)) 300 + minimun = int(round((min_position - PUSH_WIDTH) / proportion + self.min_range))
271 301
272 return minimun 302 return minimun
273 303
@@ -313,18 +343,20 @@ class GradientSlider(wx.Panel): @@ -313,18 +343,20 @@ class GradientSlider(wx.Panel):
313 return self.minimun 343 return self.minimun
314 344
315 def _generate_event(self, event): 345 def _generate_event(self, event):
316 - evt = SliderEvent(event, self.GetId(), self.min_range,  
317 - self.max_range, self.minimun, self.maximun) 346 + evt = SliderEvent(
  347 + event,
  348 + self.GetId(),
  349 + self.min_range,
  350 + self.max_range,
  351 + self.minimun,
  352 + self.maximun,
  353 + )
318 self.GetEventHandler().ProcessEvent(evt) 354 self.GetEventHandler().ProcessEvent(evt)
319 355
320 356
321 class GradientCtrl(wx.Panel): 357 class GradientCtrl(wx.Panel):
322 def __init__(self, parent, id, minRange, maxRange, minValue, maxValue, colour): 358 def __init__(self, parent, id, minRange, maxRange, minValue, maxValue, colour):
323 super(GradientCtrl, self).__init__(parent, id) 359 super(GradientCtrl, self).__init__(parent, id)
324 - self.sizer = wx.BoxSizer(wx.HORIZONTAL)  
325 - self.SetSizer(self.sizer)  
326 - self.sizer.Fit(self)  
327 - self.SetAutoLayout(1)  
328 self.min_range = minRange 360 self.min_range = minRange
329 self.max_range = maxRange 361 self.max_range = maxRange
330 self.minimun = minValue 362 self.minimun = minValue
@@ -336,43 +368,56 @@ class GradientCtrl(wx.Panel): @@ -336,43 +368,56 @@ class GradientCtrl(wx.Panel):
336 self.Show() 368 self.Show()
337 369
338 def _draw_controls(self): 370 def _draw_controls(self):
339 - self.gradient_slider = GradientSlider(self, -1, self.min_range,  
340 - self.max_range, self.minimun,  
341 - self.maximun, self.colour)  
342 -  
343 - self.spin_min = intctrl.IntCtrl(self, size=(40,20),  
344 - style=wx.TE_PROCESS_ENTER)  
345 - self.spin_min.SetValue(self.minimun)  
346 - if sys.platform != 'win32': 371 + self.gradient_slider = GradientSlider(
  372 + self,
  373 + -1,
  374 + self.min_range,
  375 + self.max_range,
  376 + self.minimun,
  377 + self.maximun,
  378 + self.colour,
  379 + )
  380 +
  381 + self.spin_min = InvSpinCtrl(
  382 + self,
  383 + value=self.minimun,
  384 + min_value=self.min_range,
  385 + max_value=self.max_range,
  386 + spin_button=False,
  387 + )
  388 + if sys.platform != "win32":
347 self.spin_min.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) 389 self.spin_min.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
348 390
349 - self.spin_max = intctrl.IntCtrl(self, size=(40,20),  
350 - style=wx.TE_PROCESS_ENTER)  
351 - self.spin_max.SetValue(self.maximun)  
352 - if sys.platform != 'win32': 391 + self.spin_max = InvSpinCtrl(
  392 + self,
  393 + value=self.maximun,
  394 + min_value=self.min_range,
  395 + max_value=self.max_range,
  396 + spin_button=False,
  397 + )
  398 + if sys.platform != "win32":
353 self.spin_max.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) 399 self.spin_max.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
354 400
  401 + self.spin_min.CalcSizeFromTextSize()
  402 + self.spin_max.CalcSizeFromTextSize()
  403 +
355 sizer = wx.BoxSizer(wx.HORIZONTAL) 404 sizer = wx.BoxSizer(wx.HORIZONTAL)
356 - sizer.Add(self.spin_min, 0, wx.EXPAND | wx.RIGHT, 2) 405 + sizer.Add(self.spin_min, 0, wx.RIGHT, 2)
357 sizer.Add(self.gradient_slider, 1, wx.EXPAND) 406 sizer.Add(self.gradient_slider, 1, wx.EXPAND)
358 - sizer.Add(self.spin_max, 0, wx.EXPAND | wx.LEFT, 2) 407 + sizer.Add(self.spin_max, 0, wx.LEFT, 2)
  408 +
  409 + self.sizer = wx.BoxSizer(wx.HORIZONTAL)
359 self.sizer.Add(sizer, 1, wx.EXPAND) 410 self.sizer.Add(sizer, 1, wx.EXPAND)
  411 + self.SetSizer(self.sizer)
  412 + self.sizer.Fit(self)
  413 + # self.SetAutoLayout(1)
360 414
361 def _bind_events_wx(self): 415 def _bind_events_wx(self):
362 self.gradient_slider.Bind(EVT_SLIDER_CHANGING, self.OnSliding) 416 self.gradient_slider.Bind(EVT_SLIDER_CHANGING, self.OnSliding)
363 self.gradient_slider.Bind(EVT_SLIDER_CHANGED, self.OnSlider) 417 self.gradient_slider.Bind(EVT_SLIDER_CHANGED, self.OnSlider)
364 418
365 - # self.spin_min.Bind(wx.lib.intctrl.EVT_INT, self.ChangeMinValue)  
366 - self.spin_min.Bind(wx.EVT_LEAVE_WINDOW, self._FireSpinMinChange)  
367 - self.spin_min.Bind(wx.EVT_KILL_FOCUS, self._FireSpinMinChange)  
368 - #self.spin_min.Bind(wx.EVT_KEY_DOWN, self._FireSpinMinChange)  
369 - self.spin_min.Bind(wx.EVT_MOUSEWHEEL, self.OnMinMouseWheel)  
370 -  
371 - # self.spin_max.Bind(wx.lib.intctrl.EVT_INT, self.ChangeMaxValue)  
372 - self.spin_max.Bind(wx.EVT_LEAVE_WINDOW, self._FireSpinMaxChange)  
373 - self.spin_max.Bind(wx.EVT_KILL_FOCUS, self._FireSpinMaxChange)  
374 - #self.spin_max.Bind(wx.EVT_KEY_DOWN, self._FireSpinMaxChange)  
375 - self.spin_max.Bind(wx.EVT_MOUSEWHEEL, self.OnMaxMouseWheel) 419 + self.spin_min.Bind(wx.EVT_SPINCTRL, self.OnMinMouseWheel)
  420 + self.spin_max.Bind(wx.EVT_SPINCTRL, self.OnMaxMouseWheel)
376 421
377 def OnSlider(self, evt): 422 def OnSlider(self, evt):
378 self.spin_min.SetValue(evt.minimun) 423 self.spin_min.SetValue(evt.minimun)
@@ -419,23 +464,23 @@ class GradientCtrl(wx.Panel): @@ -419,23 +464,23 @@ class GradientCtrl(wx.Panel):
419 self._GenerateEvent(myEVT_THRESHOLD_CHANGED) 464 self._GenerateEvent(myEVT_THRESHOLD_CHANGED)
420 465
421 def OnMinMouseWheel(self, e): 466 def OnMinMouseWheel(self, e):
422 - """ 467 + """
423 When the user wheel the mouse over min texbox 468 When the user wheel the mouse over min texbox
424 """ 469 """
425 - v = self.GetMinValue() + e.GetWheelRotation()/e.GetWheelDelta() 470 + v = self.spin_min.GetValue()
426 self.SetMinValue(v) 471 self.SetMinValue(v)
427 self._GenerateEvent(myEVT_THRESHOLD_CHANGING) 472 self._GenerateEvent(myEVT_THRESHOLD_CHANGING)
428 473
429 def OnMaxMouseWheel(self, e): 474 def OnMaxMouseWheel(self, e):
430 - """ 475 + """
431 When the user wheel the mouse over max texbox 476 When the user wheel the mouse over max texbox
432 """ 477 """
433 - v = self.GetMaxValue() + e.GetWheelRotation()/e.GetWheelDelta() 478 + v = self.spin_max.GetValue()
434 self.SetMaxValue(v) 479 self.SetMaxValue(v)
435 self._GenerateEvent(myEVT_THRESHOLD_CHANGING) 480 self._GenerateEvent(myEVT_THRESHOLD_CHANGING)
436 481
437 def SetColour(self, colour): 482 def SetColour(self, colour):
438 - colour = list(colour[:3]) + [90,] 483 + colour = list(colour[:3]) + [90]
439 self.colour = colour 484 self.colour = colour
440 self.gradient_slider.SetColour(colour) 485 self.gradient_slider.SetColour(colour)
441 self.gradient_slider.Refresh() 486 self.gradient_slider.Refresh()
@@ -443,24 +488,40 @@ class GradientCtrl(wx.Panel): @@ -443,24 +488,40 @@ class GradientCtrl(wx.Panel):
443 def SetMaxRange(self, value): 488 def SetMaxRange(self, value):
444 self.spin_min.SetMax(value) 489 self.spin_min.SetMax(value)
445 self.spin_max.SetMax(value) 490 self.spin_max.SetMax(value)
  491 + self.spin_min.CalcSizeFromTextSize()
  492 + self.spin_max.CalcSizeFromTextSize()
446 self.gradient_slider.SetMaxRange(value) 493 self.gradient_slider.SetMaxRange(value)
447 self.max_range = value 494 self.max_range = value
448 if value > self.max_range: 495 if value > self.max_range:
449 value = self.max_range 496 value = self.max_range
450 497
  498 + self.spin_min.CalcSizeFromTextSize()
  499 + self.spin_max.CalcSizeFromTextSize()
  500 + self.Layout()
  501 +
451 def SetMinRange(self, value): 502 def SetMinRange(self, value):
452 self.spin_min.SetMin(value) 503 self.spin_min.SetMin(value)
453 self.spin_max.SetMin(value) 504 self.spin_max.SetMin(value)
  505 + self.spin_min.CalcSizeFromTextSize()
  506 + self.spin_max.CalcSizeFromTextSize()
454 self.gradient_slider.SetMinRange(value) 507 self.gradient_slider.SetMinRange(value)
455 self.min_range = value 508 self.min_range = value
456 if value < self.min_range: 509 if value < self.min_range:
457 value = self.min_range 510 value = self.min_range
458 511
  512 + self.spin_min.CalcSizeFromTextSize()
  513 + self.spin_max.CalcSizeFromTextSize()
  514 + self.Layout()
  515 +
459 def SetMaxValue(self, value): 516 def SetMaxValue(self, value):
460 if value is not None: 517 if value is not None:
461 value = int(value) 518 value = int(value)
462 if value > self.max_range: 519 if value > self.max_range:
463 value = int(self.max_range) 520 value = int(self.max_range)
  521 + if value < self.min_range:
  522 + value = int(self.min_range)
  523 + if value < self.minimun:
  524 + value = int(self.minimun)
464 self.spin_max.SetValue(value) 525 self.spin_max.SetValue(value)
465 self.gradient_slider.SetMaximun(value) 526 self.gradient_slider.SetMaximun(value)
466 self.maximun = value 527 self.maximun = value
@@ -470,6 +531,10 @@ class GradientCtrl(wx.Panel): @@ -470,6 +531,10 @@ class GradientCtrl(wx.Panel):
470 value = int(value) 531 value = int(value)
471 if value < self.min_range: 532 if value < self.min_range:
472 value = int(self.min_range) 533 value = int(self.min_range)
  534 + if value > self.max_range:
  535 + value = int(self.max_range)
  536 + if value > self.maximun:
  537 + value = int(self.maximun)
473 self.spin_min.SetValue(value) 538 self.spin_min.SetValue(value)
474 self.gradient_slider.SetMinimun(value) 539 self.gradient_slider.SetMinimun(value)
475 self.minimun = value 540 self.minimun = value
@@ -497,9 +562,15 @@ class GradientCtrl(wx.Panel): @@ -497,9 +562,15 @@ class GradientCtrl(wx.Panel):
497 def _GenerateEvent(self, event): 562 def _GenerateEvent(self, event):
498 if event == myEVT_THRESHOLD_CHANGING: 563 if event == myEVT_THRESHOLD_CHANGING:
499 self.changed = True 564 self.changed = True
500 - elif event == myEVT_THRESHOLD_CHANGED : 565 + elif event == myEVT_THRESHOLD_CHANGED:
501 self.changed = False 566 self.changed = False
502 567
503 - evt = SliderEvent(event, self.GetId(), self.min_range,  
504 - self.max_range, self.minimun, self.maximun) 568 + evt = SliderEvent(
  569 + event,
  570 + self.GetId(),
  571 + self.min_range,
  572 + self.max_range,
  573 + self.minimun,
  574 + self.maximun,
  575 + )
505 self.GetEventHandler().ProcessEvent(evt) 576 self.GetEventHandler().ProcessEvent(evt)
invesalius/gui/widgets/inv_spinctrl.py 0 → 100644
@@ -0,0 +1,331 @@ @@ -0,0 +1,331 @@
  1 +# --------------------------------------------------------------------------
  2 +# Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas
  3 +# Copyright: (C) 2001 Centro de Pesquisas Renato Archer
  4 +# Homepage: http://www.softwarepublico.gov.br
  5 +# Contact: invesalius@cti.gov.br
  6 +# License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt)
  7 +# --------------------------------------------------------------------------
  8 +# Este programa e software livre; voce pode redistribui-lo e/ou
  9 +# modifica-lo sob os termos da Licenca Publica Geral GNU, conforme
  10 +# publicada pela Free Software Foundation; de acordo com a versao 2
  11 +# da Licenca.
  12 +#
  13 +# Este programa eh distribuido na expectativa de ser util, mas SEM
  14 +# QUALQUER GARANTIA; sem mesmo a garantia implicita de
  15 +# COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM
  16 +# PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais
  17 +# detalhes.
  18 +# --------------------------------------------------------------------------
  19 +import decimal
  20 +
  21 +import wx
  22 +
  23 +
  24 +class InvSpinCtrl(wx.Panel):
  25 + def __init__(
  26 + self,
  27 + parent,
  28 + id=wx.ID_ANY,
  29 + value=0,
  30 + min_value=1,
  31 + max_value=100,
  32 + increment=1,
  33 + spin_button=True,
  34 + size=wx.DefaultSize,
  35 + style=wx.TE_RIGHT,
  36 + ):
  37 + super().__init__(parent, id, size=size)
  38 +
  39 + self._textctrl = wx.TextCtrl(self, -1, style=style)
  40 + if spin_button and wx.Platform != "__WXGTK__":
  41 + self._spinbtn = wx.SpinButton(self, -1)
  42 + else:
  43 + self._spinbtn = None
  44 +
  45 + self._value = 0
  46 + self._last_value = 0
  47 + self._min_value = 0
  48 + self._max_value = 100
  49 + self._increment = 1
  50 +
  51 + self.SetMin(min_value)
  52 + self.SetMax(max_value)
  53 + self.SetValue(value)
  54 + self.SetIncrement(increment)
  55 +
  56 + sizer = wx.BoxSizer(wx.HORIZONTAL)
  57 + sizer.Add(self._textctrl, 1, wx.EXPAND)
  58 + if self._spinbtn:
  59 + sizer.Add(self._spinbtn, 0, wx.EXPAND)
  60 +
  61 + self.SetSizer(sizer)
  62 + sizer.Fit(self)
  63 +
  64 + self.__bind_events()
  65 +
  66 + def __bind_events(self):
  67 + self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
  68 + self._textctrl.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
  69 + if self._spinbtn:
  70 + self._spinbtn.Bind(wx.EVT_SPIN_UP, self.OnSpinUp)
  71 + self._spinbtn.Bind(wx.EVT_SPIN_DOWN, self.OnSpinDown)
  72 +
  73 + def SetIncrement(self, increment):
  74 + self._increment = increment
  75 +
  76 + def SetMin(self, min_value):
  77 + self._min_value = min_value
  78 + self.SetValue(self._value)
  79 +
  80 + def SetMax(self, max_value):
  81 + self._max_value = max_value
  82 + self.SetValue(self._value)
  83 +
  84 + def SetRange(self, min_value, max_value):
  85 + self.SetMin(min_value)
  86 + self.SetMax(max_value)
  87 +
  88 + def GetValue(self):
  89 + return self._value
  90 +
  91 + def SetValue(self, value):
  92 + try:
  93 + value = int(value)
  94 + except ValueError:
  95 + value = self._last_value
  96 +
  97 + if value < self._min_value:
  98 + value = self._min_value
  99 +
  100 + if value > self._max_value:
  101 + value = self._max_value
  102 +
  103 + self._value = value
  104 + self._textctrl.SetValue("{}".format(self._value))
  105 + self._last_value = self._value
  106 +
  107 + def CalcSizeFromTextSize(self, text=None):
  108 + # To calculate best width to spinctrl
  109 + if text is None:
  110 + text = "{}".format(
  111 + max(len(str(self._max_value)), len(str(self._min_value))) * "M"
  112 + )
  113 +
  114 + dc = wx.WindowDC(self)
  115 + dc.SetFont(self.GetFont())
  116 + width, height = dc.GetTextExtent(text)
  117 +
  118 + if self._spinbtn:
  119 + spin = wx.SpinCtrl(self, -1)
  120 + spin_width, spin_height = spin.GetBestSize()
  121 + spin.Destroy()
  122 +
  123 + spinb = wx.SpinButton(self, -1)
  124 + spinb_width, spinb_height = spinb.GetBestSize()
  125 + spinb.Destroy()
  126 +
  127 + width += spinb_width
  128 + if wx.Platform == "__WXMAC":
  129 + height = max(height, spin_height, spinb_height)
  130 + else:
  131 + height = spin_height
  132 + else:
  133 + height = -1
  134 +
  135 + self.SetMinSize((width, height))
  136 + self.Layout()
  137 +
  138 + def OnMouseWheel(self, evt):
  139 + r = evt.GetWheelRotation()
  140 + if r > 0:
  141 + self.SetValue(self.GetValue() + self._increment)
  142 + else:
  143 + self.SetValue(self.GetValue() - self._increment)
  144 + self.raise_event()
  145 + evt.Skip()
  146 +
  147 + def OnKillFocus(self, evt):
  148 + value = self._textctrl.GetValue()
  149 + self.SetValue(value)
  150 + self.raise_event()
  151 + evt.Skip()
  152 +
  153 + def OnSpinDown(self, evt):
  154 + self.SetValue(self.GetValue() - self._increment)
  155 + self.raise_event()
  156 + evt.Skip()
  157 +
  158 + def OnSpinUp(self, evt):
  159 + self.SetValue(self.GetValue() + self._increment)
  160 + self.raise_event()
  161 + evt.Skip()
  162 +
  163 + def raise_event(self):
  164 + event = wx.PyCommandEvent(wx.EVT_SPINCTRL.typeId, self.GetId())
  165 + self.GetEventHandler().ProcessEvent(event)
  166 +
  167 +
  168 +class InvFloatSpinCtrl(wx.Panel):
  169 + def __init__(
  170 + self,
  171 + parent,
  172 + id=wx.ID_ANY,
  173 + value=0.0,
  174 + min_value=1.0,
  175 + max_value=100.0,
  176 + increment=0.1,
  177 + digits=1,
  178 + spin_button=True,
  179 + size=wx.DefaultSize,
  180 + style=wx.TE_RIGHT,
  181 + ):
  182 + super().__init__(parent, id, size=size)
  183 +
  184 + self._textctrl = wx.TextCtrl(self, -1, style=style)
  185 + if spin_button and wx.Platform != "__WXGTK__":
  186 + self._spinbtn = wx.SpinButton(self, -1)
  187 + else:
  188 + self._spinbtn = None
  189 +
  190 + self._digits = digits
  191 + self._dec_context = decimal.Context(prec=digits)
  192 +
  193 + self._value = decimal.Decimal("0", self._dec_context)
  194 + self._last_value = self._value
  195 + self._min_value = decimal.Decimal("0", self._dec_context)
  196 + self._max_value = decimal.Decimal("100", self._dec_context)
  197 + self._increment = decimal.Decimal("0.1", self._dec_context)
  198 +
  199 + self.SetIncrement(increment)
  200 + self.SetMin(min_value)
  201 + self.SetMax(max_value)
  202 + self.SetValue(value)
  203 +
  204 + sizer = wx.BoxSizer(wx.HORIZONTAL)
  205 + sizer.Add(self._textctrl, 1, wx.EXPAND)
  206 + if self._spinbtn:
  207 + sizer.Add(self._spinbtn, 0, wx.EXPAND)
  208 +
  209 + self.SetSizer(sizer)
  210 + sizer.Fit(self)
  211 +
  212 + self.__bind_events()
  213 +
  214 + def __bind_events(self):
  215 + self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
  216 + self._textctrl.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus)
  217 + if self._spinbtn:
  218 + self._spinbtn.Bind(wx.EVT_SPIN_UP, self.OnSpinUp)
  219 + self._spinbtn.Bind(wx.EVT_SPIN_DOWN, self.OnSpinDown)
  220 +
  221 + def _to_decimal(self, value):
  222 + if not isinstance(value, str):
  223 + value = "{:.{digits}f}".format(value, digits=self._digits)
  224 + return decimal.Decimal(value, self._dec_context)
  225 +
  226 + def SetDigits(self, digits):
  227 + self._digits = digits
  228 + self._dec_context = decimal.Context(prec=digits)
  229 +
  230 + self.SetIncrement(self._increment)
  231 + self.SetMin(self._min_value)
  232 + self.SetMax(self._max_value)
  233 + self.SetValue(self._value)
  234 +
  235 + def SetIncrement(self, increment):
  236 + self._increment = self._to_decimal(increment)
  237 +
  238 + def SetMin(self, min_value):
  239 + self._min_value = self._to_decimal(min_value)
  240 + self.SetValue(self._value)
  241 +
  242 + def SetMax(self, max_value):
  243 + self._max_value = self._to_decimal(max_value)
  244 + self.SetValue(self._value)
  245 +
  246 + def SetRange(self, min_value, max_value):
  247 + self.SetMin(min_value)
  248 + self.SetMax(max_value)
  249 +
  250 + def GetValue(self):
  251 + return float(self._value)
  252 +
  253 + def SetValue(self, value):
  254 + try:
  255 + value = self._to_decimal(value)
  256 + except decimal.InvalidOperation:
  257 + value = self._last_value
  258 +
  259 + if value < self._min_value:
  260 + value = self._min_value
  261 +
  262 + if value > self._max_value:
  263 + value = self._max_value
  264 +
  265 + self._value = value
  266 + self._textctrl.SetValue("{}".format(self._value))
  267 + self._last_value = self._value
  268 +
  269 + def CalcSizeFromTextSize(self, text=None):
  270 + # To calculate best width to spinctrl
  271 + if text is None:
  272 + text = "{}".format(
  273 + max(len(str(self._max_value)), len(str(self._min_value))) * "M"
  274 + )
  275 +
  276 + dc = wx.WindowDC(self)
  277 + dc.SetFont(self.GetFont())
  278 + width, height = dc.GetTextExtent(text)
  279 +
  280 + spin = wx.SpinCtrl(self, -1)
  281 + spin_width, spin_height = spin.GetBestSize()
  282 + spin.Destroy()
  283 +
  284 + if self._spinbtn:
  285 + spin = wx.SpinCtrl(self, -1)
  286 + spin_width, spin_height = spin.GetBestSize()
  287 + spin.Destroy()
  288 +
  289 + spinb = wx.SpinButton(self, -1)
  290 + spinb_width, spinb_height = spinb.GetBestSize()
  291 + spinb.Destroy()
  292 +
  293 + width += spinb_width
  294 + if wx.Platform == "__WXMAC":
  295 + height = max(height, spin_height, spinb_height)
  296 + else:
  297 + height = spin_height
  298 + else:
  299 + height = -1
  300 +
  301 + self.SetMinSize((width, height))
  302 + self.Layout()
  303 +
  304 + def OnMouseWheel(self, evt):
  305 + r = evt.GetWheelRotation()
  306 + if r > 0:
  307 + self.SetValue(self._value + self._increment)
  308 + else:
  309 + self.SetValue(self._value - self._increment)
  310 + self.raise_event()
  311 + evt.Skip()
  312 +
  313 + def OnKillFocus(self, evt):
  314 + value = self._textctrl.GetValue()
  315 + self.SetValue(value)
  316 + self.raise_event()
  317 + evt.Skip()
  318 +
  319 + def OnSpinDown(self, evt):
  320 + self.SetValue(self._value - self._increment)
  321 + self.raise_event()
  322 + evt.Skip()
  323 +
  324 + def OnSpinUp(self, evt):
  325 + self.SetValue(self._value + self._increment)
  326 + self.raise_event()
  327 + evt.Skip()
  328 +
  329 + def raise_event(self):
  330 + event = wx.PyCommandEvent(wx.EVT_SPINCTRL.typeId, self.GetId())
  331 + self.GetEventHandler().ProcessEvent(event)
invesalius/gui/widgets/listctrl.py
@@ -739,7 +739,7 @@ class TextEditMixin: @@ -739,7 +739,7 @@ class TextEditMixin:
739 # data source 739 # data source
740 self.SetVirtualData(self.curRow, self.curCol, text) 740 self.SetVirtualData(self.curRow, self.curCol, text)
741 else: 741 else:
742 - self.SetStringItem(self.curRow, self.curCol, text) 742 + self.SetItem(self.curRow, self.curCol, text)
743 self.RefreshItem(self.curRow) 743 self.RefreshItem(self.curRow)
744 744
745 def _SelectIndex(self, row): 745 def _SelectIndex(self, row):
invesalius/gui/widgets/slice_menu.py
@@ -57,14 +57,14 @@ class SliceMenu(wx.Menu): @@ -57,14 +57,14 @@ class SliceMenu(wx.Menu):
57 new_id = self.id_wl_first = wx.NewId() 57 new_id = self.id_wl_first = wx.NewId()
58 wl_item = wx.MenuItem(submenu_wl, new_id,\ 58 wl_item = wx.MenuItem(submenu_wl, new_id,\
59 _('Default'), kind=wx.ITEM_RADIO) 59 _('Default'), kind=wx.ITEM_RADIO)
60 - submenu_wl.AppendItem(wl_item) 60 + submenu_wl.Append(wl_item)
61 self.ID_TO_TOOL_ITEM[new_id] = wl_item 61 self.ID_TO_TOOL_ITEM[new_id] = wl_item
62 62
63 #Case the user change window and level 63 #Case the user change window and level
64 new_id = self.other_wl_id = wx.NewId() 64 new_id = self.other_wl_id = wx.NewId()
65 wl_item = wx.MenuItem(submenu_wl, new_id,\ 65 wl_item = wx.MenuItem(submenu_wl, new_id,\
66 _('Manual'), kind=wx.ITEM_RADIO) 66 _('Manual'), kind=wx.ITEM_RADIO)
67 - submenu_wl.AppendItem(wl_item) 67 + submenu_wl.Append(wl_item)
68 self.ID_TO_TOOL_ITEM[new_id] = wl_item 68 self.ID_TO_TOOL_ITEM[new_id] = wl_item
69 69
70 for name in sorted(const.WINDOW_LEVEL): 70 for name in sorted(const.WINDOW_LEVEL):
@@ -72,7 +72,7 @@ class SliceMenu(wx.Menu): @@ -72,7 +72,7 @@ class SliceMenu(wx.Menu):
72 new_id = wx.NewId() 72 new_id = wx.NewId()
73 wl_item = wx.MenuItem(submenu_wl, new_id,\ 73 wl_item = wx.MenuItem(submenu_wl, new_id,\
74 name, kind=wx.ITEM_RADIO) 74 name, kind=wx.ITEM_RADIO)
75 - submenu_wl.AppendItem(wl_item) 75 + submenu_wl.Append(wl_item)
76 self.ID_TO_TOOL_ITEM[new_id] = wl_item 76 self.ID_TO_TOOL_ITEM[new_id] = wl_item
77 77
78 #----------- Sub menu of the save and load options --------- 78 #----------- Sub menu of the save and load options ---------
@@ -84,7 +84,7 @@ class SliceMenu(wx.Menu): @@ -84,7 +84,7 @@ class SliceMenu(wx.Menu):
84 # new_id = wx.NewId() 84 # new_id = wx.NewId()
85 # wl_item = wx.MenuItem(submenu_wl, new_id,\ 85 # wl_item = wx.MenuItem(submenu_wl, new_id,\
86 # name) 86 # name)
87 - # submenu_wl.AppendItem(wl_item) 87 + # submenu_wl.Append(wl_item)
88 # self.ID_TO_TOOL_ITEM[new_id] = wl_item 88 # self.ID_TO_TOOL_ITEM[new_id] = wl_item
89 89
90 90
@@ -100,7 +100,7 @@ class SliceMenu(wx.Menu): @@ -100,7 +100,7 @@ class SliceMenu(wx.Menu):
100 new_id = self.id_pseudo_first = wx.NewId() 100 new_id = self.id_pseudo_first = wx.NewId()
101 color_item = wx.MenuItem(submenu_pseudo_colours, new_id,\ 101 color_item = wx.MenuItem(submenu_pseudo_colours, new_id,\
102 _("Default "), kind=mkind) 102 _("Default "), kind=mkind)
103 - submenu_pseudo_colours.AppendItem(color_item) 103 + submenu_pseudo_colours.Append(color_item)
104 color_item.Check(1) 104 color_item.Check(1)
105 self.ID_TO_TOOL_ITEM[new_id] = color_item 105 self.ID_TO_TOOL_ITEM[new_id] = color_item
106 self.pseudo_color_items[new_id] = color_item 106 self.pseudo_color_items[new_id] = color_item
@@ -110,7 +110,7 @@ class SliceMenu(wx.Menu): @@ -110,7 +110,7 @@ class SliceMenu(wx.Menu):
110 new_id = wx.NewId() 110 new_id = wx.NewId()
111 color_item = wx.MenuItem(submenu_wl, new_id,\ 111 color_item = wx.MenuItem(submenu_wl, new_id,\
112 name, kind=mkind) 112 name, kind=mkind)
113 - submenu_pseudo_colours.AppendItem(color_item) 113 + submenu_pseudo_colours.Append(color_item)
114 self.ID_TO_TOOL_ITEM[new_id] = color_item 114 self.ID_TO_TOOL_ITEM[new_id] = color_item
115 self.pseudo_color_items[new_id] = color_item 115 self.pseudo_color_items[new_id] = color_item
116 116
@@ -119,14 +119,14 @@ class SliceMenu(wx.Menu): @@ -119,14 +119,14 @@ class SliceMenu(wx.Menu):
119 new_id = wx.NewId() 119 new_id = wx.NewId()
120 color_item = wx.MenuItem(submenu_wl, new_id, name, 120 color_item = wx.MenuItem(submenu_wl, new_id, name,
121 kind=mkind) 121 kind=mkind)
122 - submenu_pseudo_colours.AppendItem(color_item) 122 + submenu_pseudo_colours.Append(color_item)
123 self.ID_TO_TOOL_ITEM[new_id] = color_item 123 self.ID_TO_TOOL_ITEM[new_id] = color_item
124 self.pseudo_color_items[new_id] = color_item 124 self.pseudo_color_items[new_id] = color_item
125 125
126 new_id = wx.NewId() 126 new_id = wx.NewId()
127 color_item = wx.MenuItem(submenu_wl, new_id, _('Custom'), 127 color_item = wx.MenuItem(submenu_wl, new_id, _('Custom'),
128 kind=mkind) 128 kind=mkind)
129 - submenu_pseudo_colours.AppendItem(color_item) 129 + submenu_pseudo_colours.Append(color_item)
130 self.ID_TO_TOOL_ITEM[new_id] = color_item 130 self.ID_TO_TOOL_ITEM[new_id] = color_item
131 self.pseudo_color_items[new_id] = color_item 131 self.pseudo_color_items[new_id] = color_item
132 132
@@ -137,7 +137,7 @@ class SliceMenu(wx.Menu): @@ -137,7 +137,7 @@ class SliceMenu(wx.Menu):
137 new_id = wx.NewId() 137 new_id = wx.NewId()
138 projection_item = wx.MenuItem(submenu_projection, new_id, name, 138 projection_item = wx.MenuItem(submenu_projection, new_id, name,
139 kind=wx.ITEM_RADIO) 139 kind=wx.ITEM_RADIO)
140 - submenu_projection.AppendItem(projection_item) 140 + submenu_projection.Append(projection_item)
141 self.ID_TO_TOOL_ITEM[new_id] = projection_item 141 self.ID_TO_TOOL_ITEM[new_id] = projection_item
142 self.projection_items[PROJECTIONS_ID[name]] = projection_item 142 self.projection_items[PROJECTIONS_ID[name]] = projection_item
143 143
@@ -148,7 +148,7 @@ class SliceMenu(wx.Menu): @@ -148,7 +148,7 @@ class SliceMenu(wx.Menu):
148 new_id = wx.NewId() 148 new_id = wx.NewId()
149 image_tiling_item = wx.MenuItem(submenu_image_tiling, new_id,\ 149 image_tiling_item = wx.MenuItem(submenu_image_tiling, new_id,\
150 name, kind=wx.ITEM_RADIO) 150 name, kind=wx.ITEM_RADIO)
151 - submenu_image_tiling.AppendItem(image_tiling_item) 151 + submenu_image_tiling.Append(image_tiling_item)
152 self.ID_TO_TOOL_ITEM[new_id] = image_tiling_item 152 self.ID_TO_TOOL_ITEM[new_id] = image_tiling_item
153 153
154 #Save first id item 154 #Save first id item
@@ -157,10 +157,10 @@ class SliceMenu(wx.Menu): @@ -157,10 +157,10 @@ class SliceMenu(wx.Menu):
157 flag_tiling = True 157 flag_tiling = True
158 158
159 # Add sub itens in the menu 159 # Add sub itens in the menu
160 - self.AppendMenu(-1, _("Window width and level"), submenu_wl)  
161 - self.AppendMenu(-1, _("Pseudo color"), submenu_pseudo_colours)  
162 - self.AppendMenu(-1, _("Projection type"), submenu_projection)  
163 - ###self.AppendMenu(-1, _("Image Tiling"), submenu_image_tiling) 160 + self.Append(-1, _("Window width and level"), submenu_wl)
  161 + self.Append(-1, _("Pseudo color"), submenu_pseudo_colours)
  162 + self.Append(-1, _("Projection type"), submenu_projection)
  163 + ###self.Append(-1, _("Image Tiling"), submenu_image_tiling)
164 164
165 # It doesn't work in Linux 165 # It doesn't work in Linux
166 self.Bind(wx.EVT_MENU, self.OnPopup) 166 self.Bind(wx.EVT_MENU, self.OnPopup)