Commit 696200d161b10c21efdaac01612fc15df181f7ed

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

Python3 and wxPython4 support (also run in Python2 and wxPython3) (#135)

* Starting to port to python3

* String decode error with python3

* More string decode and print

* More errors with wxpython modules

* More errors with wxpython modules and prints

* More errors with wxpython modules, prints and xrange

* wx hyperlink import errors

* print, xrange and wx import errors on tasks

* more print and xrange errors

* more print and xrange errors in dicom reader

* taskbaricon error

* print and xrange errors in surface code parts

* print and xrange errors

* metaclass in python3 using six

* StringIO to BytesIO

* Hyperlinkctrl errors

* SystemSettings errors

* AddSizer -> Add

* More hyperlink errors

* AddSpacer -> Add

* Temporary fixes

* Temporary fixes

* Creating preferences dialog

* Update checking working

* presets and other errors

* Opening inv3 proj

* Measures and gradiente widget (from manual segmentation) working

* Task thresholding, manual segmentation and watershed working

* Changed a bunch of xrange to range

* Opening dicom from command line

* Opening dicom by the gui

* Showing raycasting

* clut raycasting working

* Changing viewer volume colour working again

* Saving inv3 files

* Surface creation dialog and mask and surface colour setting

* Region growing gui working again

* Crop mask working again

* Reorient image working again

* New mask gui dialog working again

* Mask boolean operations working again

* Fill holes manually working again

* Fill holes automatically working again

* Fill holes automatically radiobox set default values

* Select parts working again

* Handling all exceptions when verifying update

* Entering in navigate mode and the navigate debug device

* Custom pseudocolor gui working again

* Opening bitmap folder working again

* Expanding watershed working again

* Resize dicom dialog gui working again

* Converted the rest of the dialogs

* Exporting mesh files

* Exporting mesh files

* Datanotebook (surface and measures) working again

* Fixed crash when closing project (because of checking an unused menu in slice viewer)

* UnIniting auimanager when closing invesalius gui

* Fill holes manually working in both wxpython 3 and 4

* Fill holes automatically working in both wxpython 3 and 4

* Crop working in both wxpython 3 and 4

* Opening bmp files working in both wxpython 3 and 4

* Colors of measures

* Changes in Neuronavigation to work with wxpython4 and python3

* Forcing surface and mask colour to always be a triple (r, g, b)

* Workaround to make InVesalius run in wxPython in Ubuntu 18.04
Showing 54 changed files with 908 additions and 571 deletions   Show diff stats
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
18 # detalhes. 18 # detalhes.
19 #------------------------------------------------------------------------- 19 #-------------------------------------------------------------------------
20 20
  21 +from __future__ import print_function
21 22
22 import multiprocessing 23 import multiprocessing
23 import optparse as op 24 import optparse as op
@@ -30,14 +31,18 @@ import re @@ -30,14 +31,18 @@ import re
30 31
31 if sys.platform == 'win32': 32 if sys.platform == 'win32':
32 import _winreg 33 import _winreg
33 -else:  
34 - if sys.platform != 'darwin':  
35 - import wxversion  
36 - #wxversion.ensureMinimal('2.8-unicode', optionsRequired=True)  
37 - #wxversion.select('2.8-unicode', optionsRequired=True)  
38 - wxversion.ensureMinimal('3.0') 34 +# else:
  35 + # if sys.platform != 'darwin':
  36 + # import wxversion
  37 + # #wxversion.ensureMinimal('2.8-unicode', optionsRequired=True)
  38 + # #wxversion.select('2.8-unicode', optionsRequired=True)
  39 + # # wxversion.ensureMinimal('4.0')
39 40
40 import wx 41 import wx
  42 +try:
  43 + from wx.adv import SplashScreen
  44 +except ImportError:
  45 + from wx import SplashScreen
41 #from wx.lib.pubsub import setupv1 #new wx 46 #from wx.lib.pubsub import setupv1 #new wx
42 from wx.lib.pubsub import setuparg1# as psv1 47 from wx.lib.pubsub import setuparg1# as psv1
43 #from wx.lib.pubsub import Publisher 48 #from wx.lib.pubsub import Publisher
@@ -64,9 +69,9 @@ if sys.platform == 'win32': @@ -64,9 +69,9 @@ if sys.platform == 'win32':
64 try: 69 try:
65 USER_DIR = expand_user() 70 USER_DIR = expand_user()
66 except: 71 except:
67 - USER_DIR = os.path.expanduser('~').decode(FS_ENCODE) 72 + USER_DIR = utils.decode(os.path.expanduser('~'), FS_ENCODE)
68 else: 73 else:
69 - USER_DIR = os.path.expanduser('~').decode(FS_ENCODE) 74 + USER_DIR = utils.decode(os.path.expanduser('~'),FS_ENCODE)
70 75
71 USER_INV_DIR = os.path.join(USER_DIR, u'.invesalius') 76 USER_INV_DIR = os.path.join(USER_DIR, u'.invesalius')
72 USER_PRESET_DIR = os.path.join(USER_INV_DIR, u'presets') 77 USER_PRESET_DIR = os.path.join(USER_INV_DIR, u'presets')
@@ -75,6 +80,15 @@ USER_LOG_DIR = os.path.join(USER_INV_DIR, u'logs') @@ -75,6 +80,15 @@ USER_LOG_DIR = os.path.join(USER_INV_DIR, u'logs')
75 80
76 # ------------------------------------------------------------------ 81 # ------------------------------------------------------------------
77 82
  83 +if sys.platform == 'linux2':
  84 + try:
  85 + tmp_var = wx.GetXDisplay
  86 + except AttributeError:
  87 + # A workaround to make InVesalius run with wxPython4 from Ubuntu 18.04
  88 + wx.GetXDisplay = lambda: None
  89 + else:
  90 + del tmp_var
  91 +
78 92
79 class InVesalius(wx.App): 93 class InVesalius(wx.App):
80 """ 94 """
@@ -89,7 +103,7 @@ class InVesalius(wx.App): @@ -89,7 +103,7 @@ class InVesalius(wx.App):
89 freeze_support() 103 freeze_support()
90 104
91 self.SetAppName("InVesalius 3") 105 self.SetAppName("InVesalius 3")
92 - self.splash = SplashScreen() 106 + self.splash = Inv3SplashScreen()
93 self.splash.Show() 107 self.splash.Show()
94 wx.CallLater(1000,self.Startup2) 108 wx.CallLater(1000,self.Startup2)
95 109
@@ -111,7 +125,7 @@ class InVesalius(wx.App): @@ -111,7 +125,7 @@ class InVesalius(wx.App):
111 125
112 # ------------------------------------------------------------------ 126 # ------------------------------------------------------------------
113 127
114 -class SplashScreen(wx.SplashScreen): 128 +class Inv3SplashScreen(SplashScreen):
115 """ 129 """
116 Splash screen to be shown in InVesalius initialization. 130 Splash screen to be shown in InVesalius initialization.
117 """ 131 """
@@ -202,16 +216,20 @@ class SplashScreen(wx.SplashScreen): @@ -202,16 +216,20 @@ class SplashScreen(wx.SplashScreen):
202 216
203 bmp = wx.Image(path).ConvertToBitmap() 217 bmp = wx.Image(path).ConvertToBitmap()
204 218
205 - style = wx.SPLASH_TIMEOUT | wx.SPLASH_CENTRE_ON_SCREEN  
206 - wx.SplashScreen.__init__(self,  
207 - bitmap=bmp,  
208 - splashStyle=style,  
209 - milliseconds=1500,  
210 - id=-1,  
211 - parent=None) 219 + try:
  220 + style = wx.adv.SPLASH_TIMEOUT | wx.adv.SPLASH_CENTRE_ON_SCREEN
  221 + except AttributeError:
  222 + style = wx.SPLASH_TIMEOUT | wx.SPLASH_CENTRE_ON_SCREEN
  223 +
  224 + SplashScreen.__init__(self,
  225 + bitmap=bmp,
  226 + splashStyle=style,
  227 + milliseconds=1500,
  228 + id=-1,
  229 + parent=None)
212 self.Bind(wx.EVT_CLOSE, self.OnClose) 230 self.Bind(wx.EVT_CLOSE, self.OnClose)
213 wx.Yield() 231 wx.Yield()
214 - wx.CallLater(200,self.Startup) 232 + wx.CallLater(200, self.Startup)
215 233
216 def Startup(self): 234 def Startup(self):
217 # Importing takes sometime, therefore it will be done 235 # Importing takes sometime, therefore it will be done
@@ -349,14 +367,14 @@ def use_cmd_optargs(options, args): @@ -349,14 +367,14 @@ def use_cmd_optargs(options, args):
349 else: 367 else:
350 for arg in reversed(args): 368 for arg in reversed(args):
351 369
352 - file = arg.decode(FS_ENCODE) 370 + file = utils.decode(arg, FS_ENCODE)
353 if os.path.isfile(file): 371 if os.path.isfile(file):
354 path = os.path.abspath(file) 372 path = os.path.abspath(file)
355 Publisher.sendMessage('Open project', path) 373 Publisher.sendMessage('Open project', path)
356 check_for_export(options) 374 check_for_export(options)
357 return True 375 return True
358 376
359 - file = arg.decode(sys.stdin.encoding) 377 + file = utils.decode(arg, sys.stdin.encoding)
360 if os.path.isfile(file): 378 if os.path.isfile(file):
361 path = os.path.abspath(file) 379 path = os.path.abspath(file)
362 Publisher.sendMessage('Open project', path) 380 Publisher.sendMessage('Open project', path)
docs/devel/example_singleton_pubsub.py
@@ -52,7 +52,7 @@ p3 = Person("Andre ") @@ -52,7 +52,7 @@ p3 = Person("Andre ")
52 people = [p1, p2, p3] 52 people = [p1, p2, p3]
53 53
54 print "Everyone eats 2 pieces:" 54 print "Everyone eats 2 pieces:"
55 -for i in xrange(2): 55 +for i in range(2):
56 for person in people: 56 for person in people:
57 person.EatPieceOfPizza() 57 person.EatPieceOfPizza()
58 58
invesalius/constants.py
@@ -23,6 +23,8 @@ import sys @@ -23,6 +23,8 @@ import sys
23 import wx 23 import wx
24 import itertools 24 import itertools
25 25
  26 +from invesalius import utils
  27 +
26 #from invesalius.project import Project 28 #from invesalius.project import Project
27 INVESALIUS_VERSION = "3.1.1" 29 INVESALIUS_VERSION = "3.1.1"
28 30
@@ -332,15 +334,15 @@ if sys.platform == 'win32': @@ -332,15 +334,15 @@ if sys.platform == 'win32':
332 try: 334 try:
333 USER_DIR = expand_user() 335 USER_DIR = expand_user()
334 except: 336 except:
335 - USER_DIR = os.path.expanduser('~').decode(FS_ENCODE) 337 + USER_DIR = utils.decode(os.path.expanduser('~'), FS_ENCODE)
336 else: 338 else:
337 - USER_DIR = os.path.expanduser('~').decode(FS_ENCODE) 339 + USER_DIR = utils.decode(os.path.expanduser('~'), FS_ENCODE)
338 340
339 USER_INV_DIR = os.path.join(USER_DIR, u'.invesalius') 341 USER_INV_DIR = os.path.join(USER_DIR, u'.invesalius')
340 USER_PRESET_DIR = os.path.join(USER_INV_DIR, u'presets') 342 USER_PRESET_DIR = os.path.join(USER_INV_DIR, u'presets')
341 USER_LOG_DIR = os.path.join(USER_INV_DIR, u'logs') 343 USER_LOG_DIR = os.path.join(USER_INV_DIR, u'logs')
342 344
343 -FILE_PATH = os.path.split(__file__)[0].decode(FS_ENCODE) 345 +FILE_PATH = utils.decode(os.path.split(__file__)[0], FS_ENCODE)
344 346
345 if hasattr(sys,"frozen") and (sys.frozen == "windows_exe"\ 347 if hasattr(sys,"frozen") and (sys.frozen == "windows_exe"\
346 or sys.frozen == "console_exe"): 348 or sys.frozen == "console_exe"):
invesalius/control.py
@@ -347,7 +347,7 @@ class Controller(): @@ -347,7 +347,7 @@ class Controller():
347 dirpath, filename = session.project_path 347 dirpath, filename = session.project_path
348 348
349 if isinstance(filename, str): 349 if isinstance(filename, str):
350 - filename = filename.decode(const.FS_ENCODE) 350 + filename = utils.decode(filename, const.FS_ENCODE)
351 351
352 proj = prj.Project() 352 proj = prj.Project()
353 prj.Project().SavePlistProject(dirpath, filename, compress) 353 prj.Project().SavePlistProject(dirpath, filename, compress)
@@ -458,7 +458,7 @@ class Controller(): @@ -458,7 +458,7 @@ class Controller():
458 def ImportMedicalImages(self, directory, gui=True): 458 def ImportMedicalImages(self, directory, gui=True):
459 patients_groups = dcm.GetDicomGroups(directory) 459 patients_groups = dcm.GetDicomGroups(directory)
460 name = directory.rpartition('\\')[-1].split('.') 460 name = directory.rpartition('\\')[-1].split('.')
461 - print "patients: ", patients_groups 461 + print("patients: ", patients_groups)
462 462
463 if len(patients_groups): 463 if len(patients_groups):
464 # OPTION 1: DICOM 464 # OPTION 1: DICOM
@@ -760,7 +760,7 @@ class Controller(): @@ -760,7 +760,7 @@ class Controller():
760 Publisher.sendMessage("Enable state project", True) 760 Publisher.sendMessage("Enable state project", True)
761 761
762 def OnOpenOtherFiles(self, pubsub_evt): 762 def OnOpenOtherFiles(self, pubsub_evt):
763 - filepath = pubsub_evt.data 763 + filepath = utils.decode(pubsub_evt.data, const.FS_ENCODE)
764 if not(filepath) == None: 764 if not(filepath) == None:
765 name = filepath.rpartition('\\')[-1].split('.') 765 name = filepath.rpartition('\\')[-1].split('.')
766 766
@@ -785,7 +785,7 @@ class Controller(): @@ -785,7 +785,7 @@ class Controller():
785 utils.debug("Not used the IPPSorter") 785 utils.debug("Not used the IPPSorter")
786 filelist = [i.image.file for i in dicom_group.GetHandSortedList()[::interval]] 786 filelist = [i.image.file for i in dicom_group.GetHandSortedList()[::interval]]
787 787
788 - if file_range != None and file_range[1] > file_range[0]: 788 + if file_range is not None and file_range[0] is not None and file_range[1] > file_range[0]:
789 filelist = filelist[file_range[0]:file_range[1] + 1] 789 filelist = filelist[file_range[0]:file_range[1] + 1]
790 790
791 zspacing = dicom_group.zspacing * interval 791 zspacing = dicom_group.zspacing * interval
@@ -828,7 +828,7 @@ class Controller(): @@ -828,7 +828,7 @@ class Controller():
828 self.matrix, scalar_range, self.filename = image_utils.dcm2memmap(filelist, size, 828 self.matrix, scalar_range, self.filename = image_utils.dcm2memmap(filelist, size,
829 orientation, resolution_percentage) 829 orientation, resolution_percentage)
830 830
831 - print xyspacing, zspacing 831 + print(xyspacing, zspacing)
832 if orientation == 'AXIAL': 832 if orientation == 'AXIAL':
833 spacing = xyspacing[0], xyspacing[1], zspacing 833 spacing = xyspacing[0], xyspacing[1], zspacing
834 elif orientation == 'CORONAL': 834 elif orientation == 'CORONAL':
@@ -893,7 +893,7 @@ class Controller(): @@ -893,7 +893,7 @@ class Controller():
893 proj = prj.Project() 893 proj = prj.Project()
894 894
895 thresh_modes = proj.threshold_modes.keys() 895 thresh_modes = proj.threshold_modes.keys()
896 - thresh_modes.sort() 896 + thresh_modes = sorted(thresh_modes)
897 default_threshold = const.THRESHOLD_PRESETS_INDEX 897 default_threshold = const.THRESHOLD_PRESETS_INDEX
898 if proj.mask_dict: 898 if proj.mask_dict:
899 keys = proj.mask_dict.keys() 899 keys = proj.mask_dict.keys()
invesalius/data/coordinates.py
@@ -47,7 +47,7 @@ def GetCoordinates(trck_init, trck_id, ref_mode): @@ -47,7 +47,7 @@ def GetCoordinates(trck_init, trck_id, ref_mode):
47 5: DebugCoord} 47 5: DebugCoord}
48 coord = getcoord[trck_id](trck_init, trck_id, ref_mode) 48 coord = getcoord[trck_id](trck_init, trck_id, ref_mode)
49 else: 49 else:
50 - print "Select Tracker" 50 + print("Select Tracker")
51 51
52 return coord 52 return coord
53 53
@@ -70,7 +70,7 @@ def ClaronCoord(trck_init, trck_id, ref_mode): @@ -70,7 +70,7 @@ def ClaronCoord(trck_init, trck_id, ref_mode):
70 k = 30 70 k = 30
71 except AttributeError: 71 except AttributeError:
72 k += 1 72 k += 1
73 - print "wait, collecting coordinates ..." 73 + print("wait, collecting coordinates ...")
74 if k == 30: 74 if k == 30:
75 coord = dynamic_reference(probe, reference) 75 coord = dynamic_reference(probe, reference)
76 coord = (coord[0] * scale[0], coord[1] * scale[1], coord[2] * scale[2], coord[3], coord[4], coord[5]) 76 coord = (coord[0] * scale[0], coord[1] * scale[1], coord[2] * scale[2], coord[3], coord[4], coord[5])
@@ -84,7 +84,7 @@ def ClaronCoord(trck_init, trck_id, ref_mode): @@ -84,7 +84,7 @@ def ClaronCoord(trck_init, trck_id, ref_mode):
84 k = 30 84 k = 30
85 except AttributeError: 85 except AttributeError:
86 k += 1 86 k += 1
87 - print "wait, collecting coordinates ..." 87 + print("wait, collecting coordinates ...")
88 88
89 Publisher.sendMessage('Sensors ID', [trck.probeID, trck.refID]) 89 Publisher.sendMessage('Sensors ID', [trck.probeID, trck.refID])
90 90
@@ -180,7 +180,7 @@ def PolhemusSerialCoord(trck_init, trck_id, ref_mode): @@ -180,7 +180,7 @@ def PolhemusSerialCoord(trck_init, trck_id, ref_mode):
180 coord = None 180 coord = None
181 181
182 if lines[0][0] != '0': 182 if lines[0][0] != '0':
183 - print "The Polhemus is not connected!" 183 + print("The Polhemus is not connected!")
184 else: 184 else:
185 for s in lines: 185 for s in lines:
186 if s[1] == '1': 186 if s[1] == '1':
@@ -198,7 +198,7 @@ def PolhemusSerialCoord(trck_init, trck_id, ref_mode): @@ -198,7 +198,7 @@ def PolhemusSerialCoord(trck_init, trck_id, ref_mode):
198 plh1 = [float(s) for s in data[1:len(data)]] 198 plh1 = [float(s) for s in data[1:len(data)]]
199 j = 1 199 j = 1
200 except: 200 except:
201 - print "error!!" 201 + print("error!!")
202 202
203 coord = data[0:6] 203 coord = data[0:6]
204 return coord 204 return coord
invesalius/data/cursor_actors.py
@@ -205,7 +205,7 @@ class CursorBase(object): @@ -205,7 +205,7 @@ class CursorBase(object):
205 205
206 def _set_colour(self, imagedata, colour): 206 def _set_colour(self, imagedata, colour):
207 scalar_range = int(imagedata.GetScalarRange()[1]) 207 scalar_range = int(imagedata.GetScalarRange()[1])
208 - r, g, b = colour 208 + r, g, b = colour[:3]
209 209
210 # map scalar values into colors 210 # map scalar values into colors
211 lut_mask = vtk.vtkLookupTable() 211 lut_mask = vtk.vtkLookupTable()
@@ -319,7 +319,7 @@ class CursorRectangle(CursorBase): @@ -319,7 +319,7 @@ class CursorRectangle(CursorBase):
319 """ 319 """
320 Function to plot the Retangle 320 Function to plot the Retangle
321 """ 321 """
322 - print "Building rectangle cursor", self.orientation 322 + print("Building rectangle cursor", self.orientation)
323 r = self.radius 323 r = self.radius
324 sx, sy, sz = self.spacing 324 sx, sy, sz = self.spacing
325 if self.orientation == 'AXIAL': 325 if self.orientation == 'AXIAL':
invesalius/data/geometry.py
@@ -18,6 +18,8 @@ @@ -18,6 +18,8 @@
18 # detalhes. 18 # detalhes.
19 #-------------------------------------------------------------------------- 19 #--------------------------------------------------------------------------
20 20
  21 +from six import with_metaclass
  22 +
21 import numpy as np 23 import numpy as np
22 import math 24 import math
23 import vtk 25 import vtk
@@ -27,14 +29,12 @@ import invesalius.utils as utils @@ -27,14 +29,12 @@ import invesalius.utils as utils
27 import invesalius.constants as const 29 import invesalius.constants as const
28 30
29 31
30 -class Box(object): 32 +class Box(with_metaclass(utils.Singleton, object)):
31 """ 33 """
32 - This class is a data structure for storing the 34 + This class is a data structure for storing the
33 coordinates (min and max) of box used in crop-mask. 35 coordinates (min and max) of box used in crop-mask.
34 """ 36 """
35 37
36 - __metaclass__= utils.Singleton  
37 -  
38 def __init__(self): 38 def __init__(self):
39 self.xi = None 39 self.xi = None
40 self.xf = None 40 self.xf = None
@@ -356,7 +356,7 @@ class DrawCrop2DRetangle(): @@ -356,7 +356,7 @@ class DrawCrop2DRetangle():
356 x_pos_sl = x_pos_sl_ * xs 356 x_pos_sl = x_pos_sl_ * xs
357 y_pos_sl = y_pos_sl_ * ys 357 y_pos_sl = y_pos_sl_ * ys
358 358
359 - for k, p in self.box.axial.iteritems(): 359 + for k, p in self.box.axial.items():
360 p0 = p[0] 360 p0 = p[0]
361 p1 = p[1] 361 p1 = p[1]
362 362
@@ -386,7 +386,7 @@ class DrawCrop2DRetangle(): @@ -386,7 +386,7 @@ class DrawCrop2DRetangle():
386 x_pos_sl = x_pos_sl_ * xs 386 x_pos_sl = x_pos_sl_ * xs
387 y_pos_sl = y_pos_sl_ * zs 387 y_pos_sl = y_pos_sl_ * zs
388 388
389 - for k, p in self.box.coronal.iteritems(): 389 + for k, p in self.box.coronal.items():
390 p0 = p[0] 390 p0 = p[0]
391 p1 = p[1] 391 p1 = p[1]
392 392
@@ -415,7 +415,7 @@ class DrawCrop2DRetangle(): @@ -415,7 +415,7 @@ class DrawCrop2DRetangle():
415 x_pos_sl = x_pos_sl_ * ys 415 x_pos_sl = x_pos_sl_ * ys
416 y_pos_sl = y_pos_sl_ * zs 416 y_pos_sl = y_pos_sl_ * zs
417 417
418 - for k, p in self.box.sagital.iteritems(): 418 + for k, p in self.box.sagital.items():
419 p0 = p[0] 419 p0 = p[0]
420 p1 = p[1] 420 p1 = p[1]
421 421
invesalius/data/imagedata_utils.py
@@ -265,7 +265,7 @@ def ExtractVOI(imagedata,xi,xf,yi,yf,zi,zf): @@ -265,7 +265,7 @@ def ExtractVOI(imagedata,xi,xf,yi,yf,zi,zf):
265 265
266 def create_dicom_thumbnails(filename, window=None, level=None): 266 def create_dicom_thumbnails(filename, window=None, level=None):
267 rvtk = vtkgdcm.vtkGDCMImageReader() 267 rvtk = vtkgdcm.vtkGDCMImageReader()
268 - rvtk.SetFileName(filename) 268 + rvtk.SetFileName(utils.encode(filename, const.FS_ENCODE))
269 rvtk.Update() 269 rvtk.Update()
270 270
271 img = rvtk.GetOutput() 271 img = rvtk.GetOutput()
@@ -278,7 +278,7 @@ def create_dicom_thumbnails(filename, window=None, level=None): @@ -278,7 +278,7 @@ def create_dicom_thumbnails(filename, window=None, level=None):
278 278
279 if dz > 1: 279 if dz > 1:
280 thumbnail_paths = [] 280 thumbnail_paths = []
281 - for i in xrange(dz): 281 + for i in range(dz):
282 img_slice = ExtractVOI(img, 0, dx-1, 0, dy-1, i, i+1) 282 img_slice = ExtractVOI(img, 0, dx-1, 0, dy-1, i, i+1)
283 283
284 colorer = vtk.vtkImageMapToWindowLevelColors() 284 colorer = vtk.vtkImageMapToWindowLevelColors()
@@ -355,7 +355,7 @@ def CreateImageData(filelist, zspacing, xyspacing,size, @@ -355,7 +355,7 @@ def CreateImageData(filelist, zspacing, xyspacing,size,
355 update_progress= vtk_utils.ShowProgress(1, dialog_type = "ProgressDialog") 355 update_progress= vtk_utils.ShowProgress(1, dialog_type = "ProgressDialog")
356 356
357 array = vtk.vtkStringArray() 357 array = vtk.vtkStringArray()
358 - for x in xrange(len(filelist)): 358 + for x in range(len(filelist)):
359 array.InsertValue(x,filelist[x]) 359 array.InsertValue(x,filelist[x])
360 360
361 reader = vtkgdcm.vtkGDCMImageReader() 361 reader = vtkgdcm.vtkGDCMImageReader()
@@ -385,7 +385,7 @@ def CreateImageData(filelist, zspacing, xyspacing,size, @@ -385,7 +385,7 @@ def CreateImageData(filelist, zspacing, xyspacing,size,
385 385
386 386
387 # Reformat each slice 387 # Reformat each slice
388 - for x in xrange(len(filelist)): 388 + for x in range(len(filelist)):
389 # TODO: We need to check this automatically according 389 # TODO: We need to check this automatically according
390 # to each computer's architecture 390 # to each computer's architecture
391 # If the resolution of the matrix is too large 391 # If the resolution of the matrix is too large
@@ -459,7 +459,7 @@ class ImageCreator: @@ -459,7 +459,7 @@ class ImageCreator:
459 update_progress= vtk_utils.ShowProgress(1, dialog_type = "ProgressDialog") 459 update_progress= vtk_utils.ShowProgress(1, dialog_type = "ProgressDialog")
460 460
461 array = vtk.vtkStringArray() 461 array = vtk.vtkStringArray()
462 - for x in xrange(len(filelist)): 462 + for x in range(len(filelist)):
463 if not self.running: 463 if not self.running:
464 return False 464 return False
465 array.InsertValue(x,filelist[x]) 465 array.InsertValue(x,filelist[x])
@@ -491,7 +491,7 @@ class ImageCreator: @@ -491,7 +491,7 @@ class ImageCreator:
491 491
492 492
493 # Reformat each slice 493 # Reformat each slice
494 - for x in xrange(len(filelist)): 494 + for x in range(len(filelist)):
495 # TODO: We need to check this automatically according 495 # TODO: We need to check this automatically according
496 # to each computer's architecture 496 # to each computer's architecture
497 # If the resolution of the matrix is too large 497 # If the resolution of the matrix is too large
@@ -683,11 +683,11 @@ def dcmmf2memmap(dcm_file, orientation): @@ -683,11 +683,11 @@ def dcmmf2memmap(dcm_file, orientation):
683 d.shape = z, y, x 683 d.shape = z, y, x
684 if orientation == 'CORONAL': 684 if orientation == 'CORONAL':
685 matrix.shape = y, z, x 685 matrix.shape = y, z, x
686 - for n in xrange(z): 686 + for n in range(z):
687 matrix[:, n, :] = d[n] 687 matrix[:, n, :] = d[n]
688 elif orientation == 'SAGITTAL': 688 elif orientation == 'SAGITTAL':
689 matrix.shape = x, z, y 689 matrix.shape = x, z, y
690 - for n in xrange(z): 690 + for n in range(z):
691 matrix[:, :, n] = d[n] 691 matrix[:, :, n] = d[n]
692 else: 692 else:
693 matrix[:] = d 693 matrix[:] = d
@@ -695,7 +695,7 @@ def dcmmf2memmap(dcm_file, orientation): @@ -695,7 +695,7 @@ def dcmmf2memmap(dcm_file, orientation):
695 matrix.flush() 695 matrix.flush()
696 scalar_range = matrix.min(), matrix.max() 696 scalar_range = matrix.min(), matrix.max()
697 697
698 - print "ORIENTATION", orientation 698 + print("ORIENTATION", orientation)
699 699
700 return matrix, spacing, scalar_range, temp_file 700 return matrix, spacing, scalar_range, temp_file
701 701
invesalius/data/mask.py
@@ -46,7 +46,7 @@ class EditionHistoryNode(object): @@ -46,7 +46,7 @@ class EditionHistoryNode(object):
46 46
47 def _save_array(self, array): 47 def _save_array(self, array):
48 np.save(self.filename, array) 48 np.save(self.filename, array)
49 - print "Saving history", self.index, self.orientation, self.filename, self.clean 49 + print("Saving history", self.index, self.orientation, self.filename, self.clean)
50 50
51 def commit_history(self, mvolume): 51 def commit_history(self, mvolume):
52 array = np.load(self.filename) 52 array = np.load(self.filename)
@@ -65,10 +65,10 @@ class EditionHistoryNode(object): @@ -65,10 +65,10 @@ class EditionHistoryNode(object):
65 elif self.orientation == 'VOLUME': 65 elif self.orientation == 'VOLUME':
66 mvolume[:] = array 66 mvolume[:] = array
67 67
68 - print "applying to", self.orientation, "at slice", self.index 68 + print("applying to", self.orientation, "at slice", self.index)
69 69
70 def __del__(self): 70 def __del__(self):
71 - print "Removing", self.filename 71 + print("Removing", self.filename)
72 os.remove(self.filename) 72 os.remove(self.filename)
73 73
74 74
@@ -99,7 +99,7 @@ class EditionHistory(object): @@ -99,7 +99,7 @@ class EditionHistory(object):
99 self.history.append(node) 99 self.history.append(node)
100 self.index += 1 100 self.index += 1
101 101
102 - print "INDEX", self.index, len(self.history), self.history 102 + print("INDEX", self.index, len(self.history), self.history)
103 Publisher.sendMessage("Enable undo", True) 103 Publisher.sendMessage("Enable undo", True)
104 Publisher.sendMessage("Enable redo", False) 104 Publisher.sendMessage("Enable redo", False)
105 105
@@ -128,7 +128,7 @@ class EditionHistory(object): @@ -128,7 +128,7 @@ class EditionHistory(object):
128 128
129 if self.index == 0: 129 if self.index == 0:
130 Publisher.sendMessage("Enable undo", False) 130 Publisher.sendMessage("Enable undo", False)
131 - print "AT", self.index, len(self.history), self.history[self.index].filename 131 + print("AT", self.index, len(self.history), self.history[self.index].filename)
132 132
133 def redo(self, mvolume, actual_slices=None): 133 def redo(self, mvolume, actual_slices=None):
134 h = self.history 134 h = self.history
@@ -156,7 +156,7 @@ class EditionHistory(object): @@ -156,7 +156,7 @@ class EditionHistory(object):
156 156
157 if self.index == len(h) - 1: 157 if self.index == len(h) - 1:
158 Publisher.sendMessage("Enable redo", False) 158 Publisher.sendMessage("Enable redo", False)
159 - print "AT", self.index, len(h), h[self.index].filename 159 + print("AT", self.index, len(h), h[self.index].filename)
160 160
161 def _reload_slice(self, index): 161 def _reload_slice(self, index):
162 Publisher.sendMessage(('Set scroll position', self.history[index].orientation), 162 Publisher.sendMessage(('Set scroll position', self.history[index].orientation),
@@ -236,7 +236,7 @@ class Mask(): @@ -236,7 +236,7 @@ class Mask():
236 236
237 mask['index'] = self.index 237 mask['index'] = self.index
238 mask['name'] = self.name 238 mask['name'] = self.name
239 - mask['colour'] = self.colour 239 + mask['colour'] = self.colour[:3]
240 mask['opacity'] = self.opacity 240 mask['opacity'] = self.opacity
241 mask['threshold_range'] = self.threshold_range 241 mask['threshold_range'] = self.threshold_range
242 mask['edition_threshold_range'] = self.edition_threshold_range 242 mask['edition_threshold_range'] = self.edition_threshold_range
@@ -289,13 +289,12 @@ class Mask(): @@ -289,13 +289,12 @@ class Mask():
289 def OnSwapVolumeAxes(self, pubsub_evt): 289 def OnSwapVolumeAxes(self, pubsub_evt):
290 axis0, axis1 = pubsub_evt.data 290 axis0, axis1 = pubsub_evt.data
291 self.matrix = self.matrix.swapaxes(axis0, axis1) 291 self.matrix = self.matrix.swapaxes(axis0, axis1)
292 - print type(self.matrix)  
293 292
294 def _save_mask(self, filename): 293 def _save_mask(self, filename):
295 shutil.copyfile(self.temp_file, filename) 294 shutil.copyfile(self.temp_file, filename)
296 295
297 def _open_mask(self, filename, shape, dtype='uint8'): 296 def _open_mask(self, filename, shape, dtype='uint8'):
298 - print ">>", filename, shape 297 + print(">>", filename, shape)
299 self.temp_file = filename 298 self.temp_file = filename
300 self.matrix = np.memmap(filename, shape=shape, dtype=dtype, mode="r+") 299 self.matrix = np.memmap(filename, shape=shape, dtype=dtype, mode="r+")
301 300
invesalius/data/measures.py
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # -*- coding: UTF-8 -*- 2 # -*- coding: UTF-8 -*-
3 3
  4 +from six import with_metaclass
  5 +
4 import math 6 import math
5 import random 7 import random
6 import sys 8 import sys
@@ -46,11 +48,10 @@ else: @@ -46,11 +48,10 @@ else:
46 MEASURE_TEXT_COLOUR = (0, 0, 0) 48 MEASURE_TEXT_COLOUR = (0, 0, 0)
47 MEASURE_TEXTBOX_COLOUR = (255, 255, 165, 255) 49 MEASURE_TEXTBOX_COLOUR = (255, 255, 165, 255)
48 50
49 -class MeasureData: 51 +class MeasureData(with_metaclass(utils.Singleton)):
50 """ 52 """
51 Responsible to keep measures data. 53 Responsible to keep measures data.
52 """ 54 """
53 - __metaclass__= utils.Singleton  
54 def __init__(self): 55 def __init__(self):
55 self.measures = {const.SURFACE: {}, 56 self.measures = {const.SURFACE: {},
56 const.AXIAL: {}, 57 const.AXIAL: {},
@@ -358,7 +359,7 @@ class Measurement(): @@ -358,7 +359,7 @@ class Measurement():
358 Measurement.general_index += 1 359 Measurement.general_index += 1
359 self.index = Measurement.general_index 360 self.index = Measurement.general_index
360 self.name = const.MEASURE_NAME_PATTERN %(self.index+1) 361 self.name = const.MEASURE_NAME_PATTERN %(self.index+1)
361 - self.colour = const.MEASURE_COLOUR.next() 362 + self.colour = next(const.MEASURE_COLOUR)
362 self.value = 0 363 self.value = 0
363 self.location = const.SURFACE # AXIAL, CORONAL, SAGITTAL 364 self.location = const.SURFACE # AXIAL, CORONAL, SAGITTAL
364 self.type = const.LINEAR # ANGULAR 365 self.type = const.LINEAR # ANGULAR
@@ -832,7 +833,7 @@ class AngularMeasure(object): @@ -832,7 +833,7 @@ class AngularMeasure(object):
832 for p in self.points: 833 for p in self.points:
833 coord.SetValue(p) 834 coord.SetValue(p)
834 cx, cy = coord.GetComputedDoubleDisplayValue(canvas.evt_renderer) 835 cx, cy = coord.GetComputedDoubleDisplayValue(canvas.evt_renderer)
835 - print cx, cy 836 + print(cx, cy)
836 # canvas.draw_circle((cx, cy), 2.5) 837 # canvas.draw_circle((cx, cy), 2.5)
837 points.append((cx, cy)) 838 points.append((cx, cy))
838 839
invesalius/data/polydata_utils.py
@@ -78,7 +78,7 @@ def FillSurfaceHole(polydata): @@ -78,7 +78,7 @@ def FillSurfaceHole(polydata):
78 Fill holes in the given polydata. 78 Fill holes in the given polydata.
79 """ 79 """
80 # Filter used to detect and fill holes. Only fill 80 # Filter used to detect and fill holes. Only fill
81 - print "Filling polydata" 81 + print("Filling polydata")
82 filled_polydata = vtk.vtkFillHolesFilter() 82 filled_polydata = vtk.vtkFillHolesFilter()
83 filled_polydata.SetInputData(polydata) 83 filled_polydata.SetInputData(polydata)
84 filled_polydata.SetHoleSize(500) 84 filled_polydata.SetHoleSize(500)
@@ -133,9 +133,9 @@ def Export(polydata, filename, bin=False): @@ -133,9 +133,9 @@ def Export(polydata, filename, bin=False):
133 133
134 def Import(filename): 134 def Import(filename):
135 reader = vtk.vtkXMLPolyDataReader() 135 reader = vtk.vtkXMLPolyDataReader()
136 - if isinstance(filename, unicode): 136 + try:
137 reader.SetFileName(filename.encode(wx.GetDefaultPyEncoding())) 137 reader.SetFileName(filename.encode(wx.GetDefaultPyEncoding()))
138 - else: 138 + except AttributeError:
139 reader.SetFileName(filename) 139 reader.SetFileName(filename)
140 reader.Update() 140 reader.Update()
141 return reader.GetOutput() 141 return reader.GetOutput()
@@ -198,7 +198,7 @@ def SplitDisconectedParts(polydata): @@ -198,7 +198,7 @@ def SplitDisconectedParts(polydata):
198 if progress: 198 if progress:
199 UpdateProgress = vu.ShowProgress(progress) 199 UpdateProgress = vu.ShowProgress(progress)
200 200
201 - for region in xrange(nregions): 201 + for region in range(nregions):
202 conn.InitializeSpecifiedRegionList() 202 conn.InitializeSpecifiedRegionList()
203 conn.AddSpecifiedRegion(region) 203 conn.AddSpecifiedRegion(region)
204 conn.Update() 204 conn.Update()
invesalius/data/slice_.py
@@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
16 # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais 16 # PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais
17 # detalhes. 17 # detalhes.
18 #-------------------------------------------------------------------------- 18 #--------------------------------------------------------------------------
  19 +from six import with_metaclass
  20 +
19 import os 21 import os
20 import tempfile 22 import tempfile
21 23
@@ -72,12 +74,10 @@ class SliceBuffer(object): @@ -72,12 +74,10 @@ class SliceBuffer(object):
72 self.vtk_mask = None 74 self.vtk_mask = None
73 75
74 76
75 -class Slice(object):  
76 - __metaclass__= utils.Singleton  
77 - # Only one slice will be initialized per time (despite several viewers  
78 - # show it from distinct perspectives).  
79 - # Therefore, we use Singleton design pattern for implementing it.  
80 - 77 +# Only one slice will be initialized per time (despite several viewers
  78 +# show it from distinct perspectives).
  79 +# Therefore, we use Singleton design pattern for implementing it.
  80 +class Slice(with_metaclass(utils.Singleton, object)):
81 def __init__(self): 81 def __init__(self):
82 self.current_mask = None 82 self.current_mask = None
83 self.blend_filter = None 83 self.blend_filter = None
@@ -841,7 +841,7 @@ class Slice(object): @@ -841,7 +841,7 @@ class Slice(object):
841 proj = Project() 841 proj = Project()
842 proj.mask_dict[index].colour = colour 842 proj.mask_dict[index].colour = colour
843 843
844 - (r,g,b) = colour 844 + (r,g,b) = colour[:3]
845 colour_wx = [r*255, g*255, b*255] 845 colour_wx = [r*255, g*255, b*255]
846 Publisher.sendMessage('Change mask colour in notebook', 846 Publisher.sendMessage('Change mask colour in notebook',
847 (index, (r,g,b))) 847 (index, (r,g,b)))
@@ -1230,7 +1230,7 @@ class Slice(object): @@ -1230,7 +1230,7 @@ class Slice(object):
1230 """ 1230 """
1231 if mask is None: 1231 if mask is None:
1232 mask = self.current_mask 1232 mask = self.current_mask
1233 - for n in xrange(1, mask.matrix.shape[0]): 1233 + for n in range(1, mask.matrix.shape[0]):
1234 if mask.matrix[n, 0, 0] == 0: 1234 if mask.matrix[n, 0, 0] == 0:
1235 m = mask.matrix[n, 1:, 1:] 1235 m = mask.matrix[n, 1:, 1:]
1236 mask.matrix[n, 1:, 1:] = self.do_threshold_to_a_slice(self.matrix[n-1], m, mask.threshold_range) 1236 mask.matrix[n, 1:, 1:] = self.do_threshold_to_a_slice(self.matrix[n-1], m, mask.threshold_range)
@@ -1260,7 +1260,7 @@ class Slice(object): @@ -1260,7 +1260,7 @@ class Slice(object):
1260 1260
1261 def do_colour_mask(self, imagedata, opacity): 1261 def do_colour_mask(self, imagedata, opacity):
1262 scalar_range = int(imagedata.GetScalarRange()[1]) 1262 scalar_range = int(imagedata.GetScalarRange()[1])
1263 - r, g, b = self.current_mask.colour 1263 + r, g, b = self.current_mask.colour[:3]
1264 1264
1265 # map scalar values into colors 1265 # map scalar values into colors
1266 lut_mask = vtk.vtkLookupTable() 1266 lut_mask = vtk.vtkLookupTable()
invesalius/data/styles.py
@@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
17 # detalhes. 17 # detalhes.
18 #-------------------------------------------------------------------------- 18 #--------------------------------------------------------------------------
19 19
  20 +from six import with_metaclass
  21 +
20 import os 22 import os
21 import multiprocessing 23 import multiprocessing
22 import tempfile 24 import tempfile
@@ -226,7 +228,7 @@ class CrossInteractorStyle(DefaultInteractorStyle): @@ -226,7 +228,7 @@ class CrossInteractorStyle(DefaultInteractorStyle):
226 def OnCrossMove(self, obj, evt): 228 def OnCrossMove(self, obj, evt):
227 # The user moved the mouse with left button pressed 229 # The user moved the mouse with left button pressed
228 if self.left_pressed: 230 if self.left_pressed:
229 - print "OnCrossMove interactor style" 231 + print("OnCrossMove interactor style")
230 iren = obj.GetInteractor() 232 iren = obj.GetInteractor()
231 self.ChangeCrossPosition(iren) 233 self.ChangeCrossPosition(iren)
232 234
@@ -716,8 +718,7 @@ class ChangeSliceInteractorStyle(DefaultInteractorStyle): @@ -716,8 +718,7 @@ class ChangeSliceInteractorStyle(DefaultInteractorStyle):
716 self.last_position = position[1] 718 self.last_position = position[1]
717 719
718 720
719 -class EditorConfig(object):  
720 - __metaclass__= utils.Singleton 721 +class EditorConfig(with_metaclass(utils.Singleton, object)):
721 def __init__(self): 722 def __init__(self):
722 self.operation = const.BRUSH_THRESH 723 self.operation = const.BRUSH_THRESH
723 self.cursor_type = const.BRUSH_CIRCLE 724 self.cursor_type = const.BRUSH_CIRCLE
@@ -759,7 +760,7 @@ class EditorInteractorStyle(DefaultInteractorStyle): @@ -759,7 +760,7 @@ class EditorInteractorStyle(DefaultInteractorStyle):
759 def SetUp(self): 760 def SetUp(self):
760 761
761 x, y = self.viewer.interactor.ScreenToClient(wx.GetMousePosition()) 762 x, y = self.viewer.interactor.ScreenToClient(wx.GetMousePosition())
762 - if self.viewer.interactor.HitTestXY(x, y) == wx.HT_WINDOW_INSIDE: 763 + if self.viewer.interactor.HitTest((x, y)) == wx.HT_WINDOW_INSIDE:
763 self.viewer.slice_data.cursor.Show() 764 self.viewer.slice_data.cursor.Show()
764 765
765 y = self.viewer.interactor.GetSize()[1] - y 766 y = self.viewer.interactor.GetSize()[1] - y
@@ -985,8 +986,7 @@ class WatershedProgressWindow(object): @@ -985,8 +986,7 @@ class WatershedProgressWindow(object):
985 self.dlg.Destroy() 986 self.dlg.Destroy()
986 987
987 988
988 -class WatershedConfig(object):  
989 - __metaclass__= utils.Singleton 989 +class WatershedConfig(with_metaclass(utils.Singleton, object)):
990 def __init__(self): 990 def __init__(self):
991 self.algorithm = "Watershed" 991 self.algorithm = "Watershed"
992 self.con_2d = 4 992 self.con_2d = 4
@@ -1069,7 +1069,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): @@ -1069,7 +1069,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle):
1069 self.viewer.OnScrollBar() 1069 self.viewer.OnScrollBar()
1070 1070
1071 x, y = self.viewer.interactor.ScreenToClient(wx.GetMousePosition()) 1071 x, y = self.viewer.interactor.ScreenToClient(wx.GetMousePosition())
1072 - if self.viewer.interactor.HitTestXY(x, y) == wx.HT_WINDOW_INSIDE: 1072 + if self.viewer.interactor.HitTest((x, y)) == wx.HT_WINDOW_INSIDE:
1073 self.viewer.slice_data.cursor.Show() 1073 self.viewer.slice_data.cursor.Show()
1074 1074
1075 y = self.viewer.interactor.GetSize()[1] - y 1075 y = self.viewer.interactor.GetSize()[1] - y
@@ -1104,7 +1104,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): @@ -1104,7 +1104,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle):
1104 if self.matrix is not None: 1104 if self.matrix is not None:
1105 self.matrix = None 1105 self.matrix = None
1106 os.remove(self.temp_file) 1106 os.remove(self.temp_file)
1107 - print "deleting", self.temp_file 1107 + print("deleting", self.temp_file)
1108 1108
1109 def _set_cursor(self): 1109 def _set_cursor(self):
1110 if self.config.cursor_type == const.BRUSH_SQUARE: 1110 if self.config.cursor_type == const.BRUSH_SQUARE:
@@ -1249,7 +1249,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): @@ -1249,7 +1249,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle):
1249 position = self.viewer.get_slice_pixel_coord_by_world_pos(*coord) 1249 position = self.viewer.get_slice_pixel_coord_by_world_pos(*coord)
1250 radius = cursor.radius 1250 radius = cursor.radius
1251 1251
1252 - if position < 0: 1252 + if isinstance(position, int) and position < 0:
1253 position = viewer.calculate_matrix_position(coord) 1253 position = viewer.calculate_matrix_position(coord)
1254 1254
1255 operation = self.config.operation 1255 operation = self.config.operation
@@ -1455,7 +1455,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle): @@ -1455,7 +1455,7 @@ class WaterShedInteractorStyle(DefaultInteractorStyle):
1455 del wp 1455 del wp
1456 1456
1457 w_x, w_y = wx.GetMousePosition() 1457 w_x, w_y = wx.GetMousePosition()
1458 - x, y = self.viewer.ScreenToClientXY(w_x, w_y) 1458 + x, y = self.viewer.ScreenToClient((w_x, w_y))
1459 flag = self.viewer.interactor.HitTest((x, y)) 1459 flag = self.viewer.interactor.HitTest((x, y))
1460 1460
1461 if flag == wx.HT_WINDOW_INSIDE: 1461 if flag == wx.HT_WINDOW_INSIDE:
@@ -1767,8 +1767,7 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle): @@ -1767,8 +1767,7 @@ class ReorientImageInteractorStyle(DefaultInteractorStyle):
1767 buffer_.discard_image() 1767 buffer_.discard_image()
1768 1768
1769 1769
1770 -class FFillConfig(object):  
1771 - __metaclass__= utils.Singleton 1770 +class FFillConfig(with_metaclass(utils.Singleton, object)):
1772 def __init__(self): 1771 def __init__(self):
1773 self.dlg_visible = False 1772 self.dlg_visible = False
1774 self.target = "2D" 1773 self.target = "2D"
@@ -1904,8 +1903,7 @@ class RemoveMaskPartsInteractorStyle(FloodFillMaskInteractorStyle): @@ -1904,8 +1903,7 @@ class RemoveMaskPartsInteractorStyle(FloodFillMaskInteractorStyle):
1904 self._progr_title = _(u"Remove part") 1903 self._progr_title = _(u"Remove part")
1905 self._progr_msg = _(u"Removing part ...") 1904 self._progr_msg = _(u"Removing part ...")
1906 1905
1907 -class CropMaskConfig(object):  
1908 - __metaclass__= utils.Singleton 1906 +class CropMaskConfig(with_metaclass(utils.Singleton, object)):
1909 def __init__(self): 1907 def __init__(self):
1910 self.dlg_visible = False 1908 self.dlg_visible = False
1911 1909
@@ -2007,8 +2005,7 @@ class CropMaskInteractorStyle(DefaultInteractorStyle): @@ -2007,8 +2005,7 @@ class CropMaskInteractorStyle(DefaultInteractorStyle):
2007 Publisher.sendMessage('Reload actual slice') 2005 Publisher.sendMessage('Reload actual slice')
2008 2006
2009 2007
2010 -class SelectPartConfig(object):  
2011 - __metaclass__= utils.Singleton 2008 +class SelectPartConfig(with_metaclass(utils.Singleton, object)):
2012 def __init__(self): 2009 def __init__(self):
2013 self.mask = None 2010 self.mask = None
2014 self.con_3d = 6 2011 self.con_3d = 6
@@ -2114,8 +2111,7 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle): @@ -2114,8 +2111,7 @@ class SelectMaskPartsInteractorStyle(DefaultInteractorStyle):
2114 self.config.mask = mask 2111 self.config.mask = mask
2115 2112
2116 2113
2117 -class FFillSegmentationConfig(object):  
2118 - __metaclass__= utils.Singleton 2114 +class FFillSegmentationConfig(with_metaclass(utils.Singleton, object)):
2119 def __init__(self): 2115 def __init__(self):
2120 self.dlg_visible = False 2116 self.dlg_visible = False
2121 self.target = "2D" 2117 self.target = "2D"
@@ -2225,7 +2221,7 @@ class FloodFillSegmentInteractorStyle(DefaultInteractorStyle): @@ -2225,7 +2221,7 @@ class FloodFillSegmentInteractorStyle(DefaultInteractorStyle):
2225 2221
2226 elif self.config.method == 'dynamic': 2222 elif self.config.method == 'dynamic':
2227 if self.config.use_ww_wl: 2223 if self.config.use_ww_wl:
2228 - print "Using WW&WL" 2224 + print("Using WW&WL")
2229 ww = self.viewer.slice_.window_width 2225 ww = self.viewer.slice_.window_width
2230 wl = self.viewer.slice_.window_level 2226 wl = self.viewer.slice_.window_level
2231 image = get_LUT_value_255(image, ww, wl) 2227 image = get_LUT_value_255(image, ww, wl)
@@ -2282,7 +2278,7 @@ class FloodFillSegmentInteractorStyle(DefaultInteractorStyle): @@ -2282,7 +2278,7 @@ class FloodFillSegmentInteractorStyle(DefaultInteractorStyle):
2282 2278
2283 elif self.config.method == 'dynamic': 2279 elif self.config.method == 'dynamic':
2284 if self.config.use_ww_wl: 2280 if self.config.use_ww_wl:
2285 - print "Using WW&WL" 2281 + print("Using WW&WL")
2286 ww = self.viewer.slice_.window_width 2282 ww = self.viewer.slice_.window_width
2287 wl = self.viewer.slice_.window_level 2283 wl = self.viewer.slice_.window_level
2288 image = get_LUT_value_255(image, ww, wl) 2284 image = get_LUT_value_255(image, ww, wl)
@@ -2335,18 +2331,18 @@ class FloodFillSegmentInteractorStyle(DefaultInteractorStyle): @@ -2335,18 +2331,18 @@ class FloodFillSegmentInteractorStyle(DefaultInteractorStyle):
2335 bool_mask = np.zeros_like(mask, dtype='bool') 2331 bool_mask = np.zeros_like(mask, dtype='bool')
2336 out_mask = np.zeros_like(mask) 2332 out_mask = np.zeros_like(mask)
2337 2333
2338 - for k in xrange(int(z-1), int(z+2)): 2334 + for k in range(int(z-1), int(z+2)):
2339 if k < 0 or k >= bool_mask.shape[0]: 2335 if k < 0 or k >= bool_mask.shape[0]:
2340 continue 2336 continue
2341 - for j in xrange(int(y-1), int(y+2)): 2337 + for j in range(int(y-1), int(y+2)):
2342 if j < 0 or j >= bool_mask.shape[1]: 2338 if j < 0 or j >= bool_mask.shape[1]:
2343 continue 2339 continue
2344 - for i in xrange(int(x-1), int(x+2)): 2340 + for i in range(int(x-1), int(x+2)):
2345 if i < 0 or i >= bool_mask.shape[2]: 2341 if i < 0 or i >= bool_mask.shape[2]:
2346 continue 2342 continue
2347 bool_mask[k, j, i] = True 2343 bool_mask[k, j, i] = True
2348 2344
2349 - for i in xrange(self.config.confid_iters): 2345 + for i in range(self.config.confid_iters):
2350 var = np.std(image[bool_mask]) 2346 var = np.std(image[bool_mask])
2351 mean = np.mean(image[bool_mask]) 2347 mean = np.mean(image[bool_mask])
2352 2348
invesalius/data/surface.py
@@ -90,7 +90,7 @@ class Surface(): @@ -90,7 +90,7 @@ class Surface():
90 90
91 filelist[vtp_filepath] = vtp_filename 91 filelist[vtp_filepath] = vtp_filename
92 92
93 - surface = {'colour': self.colour, 93 + surface = {'colour': self.colour[:3],
94 'index': self.index, 94 'index': self.index,
95 'name': self.name, 95 'name': self.name,
96 'polydata': vtp_filename, 96 'polydata': vtp_filename,
@@ -361,7 +361,7 @@ class SurfaceManager(): @@ -361,7 +361,7 @@ class SurfaceManager():
361 area = measured_polydata.GetSurfaceArea() 361 area = measured_polydata.GetSurfaceArea()
362 surface.volume = volume 362 surface.volume = volume
363 surface.area = area 363 surface.area = area
364 - print ">>>>", surface.volume 364 + print(">>>>", surface.volume)
365 else: 365 else:
366 surface.volume = volume 366 surface.volume = volume
367 surface.area = area 367 surface.area = area
@@ -430,7 +430,7 @@ class SurfaceManager(): @@ -430,7 +430,7 @@ class SurfaceManager():
430 actor.SetMapper(mapper) 430 actor.SetMapper(mapper)
431 431
432 # Set actor colour and transparency 432 # Set actor colour and transparency
433 - actor.GetProperty().SetColor(surface.colour) 433 + actor.GetProperty().SetColor(surface.colour[:3])
434 actor.GetProperty().SetOpacity(1-surface.transparency) 434 actor.GetProperty().SetOpacity(1-surface.transparency)
435 435
436 self.actors_dict[surface.index] = actor 436 self.actors_dict[surface.index] = actor
@@ -471,7 +471,7 @@ class SurfaceManager(): @@ -471,7 +471,7 @@ class SurfaceManager():
471 471
472 mode = 'CONTOUR' # 'GRAYSCALE' 472 mode = 'CONTOUR' # 'GRAYSCALE'
473 min_value, max_value = mask.threshold_range 473 min_value, max_value = mask.threshold_range
474 - colour = mask.colour 474 + colour = mask.colour[:3]
475 475
476 try: 476 try:
477 overwrite = surface_parameters['options']['overwrite'] 477 overwrite = surface_parameters['options']['overwrite']
@@ -521,7 +521,7 @@ class SurfaceManager(): @@ -521,7 +521,7 @@ class SurfaceManager():
521 q_out = multiprocessing.Queue() 521 q_out = multiprocessing.Queue()
522 522
523 p = [] 523 p = []
524 - for i in xrange(n_processors): 524 + for i in range(n_processors):
525 sp = surface_process.SurfaceProcess(pipe_in, filename_img, 525 sp = surface_process.SurfaceProcess(pipe_in, filename_img,
526 matrix.shape, matrix.dtype, 526 matrix.shape, matrix.dtype,
527 mask.temp_file, 527 mask.temp_file,
@@ -539,12 +539,12 @@ class SurfaceManager(): @@ -539,12 +539,12 @@ class SurfaceManager():
539 p.append(sp) 539 p.append(sp)
540 sp.start() 540 sp.start()
541 541
542 - for i in xrange(n_pieces): 542 + for i in range(n_pieces):
543 init = i * piece_size 543 init = i * piece_size
544 end = init + piece_size + o_piece 544 end = init + piece_size + o_piece
545 roi = slice(init, end) 545 roi = slice(init, end)
546 q_in.put(roi) 546 q_in.put(roi)
547 - print "new_piece", roi 547 + print("new_piece", roi)
548 548
549 for i in p: 549 for i in p:
550 q_in.put(None) 550 q_in.put(None)
@@ -664,7 +664,7 @@ class SurfaceManager(): @@ -664,7 +664,7 @@ class SurfaceManager():
664 664
665 665
666 if decimate_reduction: 666 if decimate_reduction:
667 - print "Decimating", decimate_reduction 667 + print("Decimating", decimate_reduction)
668 decimation = vtk.vtkQuadricDecimation() 668 decimation = vtk.vtkQuadricDecimation()
669 # decimation.ReleaseDataFlagOn() 669 # decimation.ReleaseDataFlagOn()
670 decimation.SetInputData(polydata) 670 decimation.SetInputData(polydata)
@@ -902,7 +902,7 @@ class SurfaceManager(): @@ -902,7 +902,7 @@ class SurfaceManager():
902 """ 902 """
903 """ 903 """
904 index, colour = pubsub_evt.data 904 index, colour = pubsub_evt.data
905 - self.actors_dict[index].GetProperty().SetColor(colour) 905 + self.actors_dict[index].GetProperty().SetColor(colour[:3])
906 # Update value in project's surface_dict 906 # Update value in project's surface_dict
907 proj = prj.Project() 907 proj = prj.Project()
908 proj.surface_dict[index].colour = colour 908 proj.surface_dict[index].colour = colour
@@ -925,7 +925,7 @@ class SurfaceManager(): @@ -925,7 +925,7 @@ class SurfaceManager():
925 temp_file = win32api.GetShortPathName(temp_file) 925 temp_file = win32api.GetShortPathName(temp_file)
926 os.remove(_temp_file) 926 os.remove(_temp_file)
927 927
928 - temp_file = temp_file.decode(const.FS_ENCODE) 928 + temp_file = utl.decode(temp_file, const.FS_ENCODE)
929 self._export_surface(temp_file, filetype) 929 self._export_surface(temp_file, filetype)
930 930
931 shutil.move(temp_file, filename) 931 shutil.move(temp_file, filename)
invesalius/data/surface_process.py
@@ -206,7 +206,7 @@ class SurfaceProcess(multiprocessing.Process): @@ -206,7 +206,7 @@ class SurfaceProcess(multiprocessing.Process):
206 writer.SetFileName(filename) 206 writer.SetFileName(filename)
207 writer.Write() 207 writer.Write()
208 208
209 - print "Writing piece", roi, "to", filename 209 + print("Writing piece", roi, "to", filename)
210 del polydata 210 del polydata
211 del writer 211 del writer
212 212
invesalius/data/trackers.py
@@ -50,10 +50,10 @@ def DefaultTracker(tracker_id): @@ -50,10 +50,10 @@ def DefaultTracker(tracker_id):
50 trck_init = None 50 trck_init = None
51 try: 51 try:
52 # import spatial tracker library 52 # import spatial tracker library
53 - print 'Connect to default tracking device.' 53 + print('Connect to default tracking device.')
54 54
55 except: 55 except:
56 - print 'Could not connect to default tracker.' 56 + print('Could not connect to default tracker.')
57 57
58 # return tracker initialization variable and type of connection 58 # return tracker initialization variable and type of connection
59 return trck_init, 'wrapper' 59 return trck_init, 'wrapper'
@@ -78,13 +78,13 @@ def ClaronTracker(tracker_id): @@ -78,13 +78,13 @@ def ClaronTracker(tracker_id):
78 78
79 if trck_init.GetIdentifyingCamera(): 79 if trck_init.GetIdentifyingCamera():
80 trck_init.Run() 80 trck_init.Run()
81 - print "MicronTracker camera identified." 81 + print("MicronTracker camera identified.")
82 else: 82 else:
83 trck_init = None 83 trck_init = None
84 84
85 except ImportError: 85 except ImportError:
86 lib_mode = 'error' 86 lib_mode = 'error'
87 - print 'The ClaronTracker library is not installed.' 87 + print('The ClaronTracker library is not installed.')
88 88
89 return trck_init, lib_mode 89 return trck_init, lib_mode
90 90
@@ -94,24 +94,24 @@ def PolhemusTracker(tracker_id): @@ -94,24 +94,24 @@ def PolhemusTracker(tracker_id):
94 trck_init = PlhWrapperConnection(tracker_id) 94 trck_init = PlhWrapperConnection(tracker_id)
95 lib_mode = 'wrapper' 95 lib_mode = 'wrapper'
96 if not trck_init: 96 if not trck_init:
97 - print 'Could not connect with Polhemus wrapper, trying USB connection...' 97 + print('Could not connect with Polhemus wrapper, trying USB connection...')
98 trck_init = PlhUSBConnection(tracker_id) 98 trck_init = PlhUSBConnection(tracker_id)
99 lib_mode = 'usb' 99 lib_mode = 'usb'
100 if not trck_init: 100 if not trck_init:
101 - print 'Could not connect with Polhemus USB, trying serial connection...' 101 + print('Could not connect with Polhemus USB, trying serial connection...')
102 trck_init = PlhSerialConnection(tracker_id) 102 trck_init = PlhSerialConnection(tracker_id)
103 lib_mode = 'serial' 103 lib_mode = 'serial'
104 except: 104 except:
105 trck_init = None 105 trck_init = None
106 lib_mode = 'error' 106 lib_mode = 'error'
107 - print 'Could not connect to Polhemus.' 107 + print('Could not connect to Polhemus.')
108 108
109 return trck_init, lib_mode 109 return trck_init, lib_mode
110 110
111 111
112 def DebugTracker(tracker_id): 112 def DebugTracker(tracker_id):
113 trck_init = True 113 trck_init = True
114 - print 'Debug device started.' 114 + print('Debug device started.')
115 return trck_init, 'debug' 115 return trck_init, 'debug'
116 116
117 117
@@ -134,10 +134,10 @@ def PlhWrapperConnection(tracker_id): @@ -134,10 +134,10 @@ def PlhWrapperConnection(tracker_id):
134 sleep(0.175) 134 sleep(0.175)
135 else: 135 else:
136 trck_init = None 136 trck_init = None
137 - print 'Could not connect to Polhemus via wrapper without error.' 137 + print('Could not connect to Polhemus via wrapper without error.')
138 except: 138 except:
139 trck_init = None 139 trck_init = None
140 - print 'Could not connect to Polhemus via wrapper with error.' 140 + print('Could not connect to Polhemus via wrapper with error.')
141 141
142 return trck_init 142 return trck_init
143 143
@@ -163,11 +163,11 @@ def PlhSerialConnection(tracker_id): @@ -163,11 +163,11 @@ def PlhSerialConnection(tracker_id):
163 163
164 if not data: 164 if not data:
165 trck_init = None 165 trck_init = None
166 - print 'Could not connect to Polhemus serial without error.' 166 + print('Could not connect to Polhemus serial without error.')
167 167
168 except: 168 except:
169 trck_init = None 169 trck_init = None
170 - print 'Could not connect to Polhemus serial with error.' 170 + print('Could not connect to Polhemus serial with error.')
171 171
172 return trck_init 172 return trck_init
173 173
@@ -198,10 +198,10 @@ def PlhUSBConnection(tracker_id): @@ -198,10 +198,10 @@ def PlhUSBConnection(tracker_id):
198 endpoint.wMaxPacketSize) 198 endpoint.wMaxPacketSize)
199 if not data: 199 if not data:
200 trck_init = None 200 trck_init = None
201 - print 'Could not connect to Polhemus USB without error.' 201 + print('Could not connect to Polhemus USB without error.')
202 202
203 except: 203 except:
204 - print 'Could not connect to Polhemus USB with error.' 204 + print('Could not connect to Polhemus USB with error.')
205 205
206 return trck_init 206 return trck_init
207 207
@@ -217,16 +217,16 @@ def DisconnectTracker(tracker_id, trck_init): @@ -217,16 +217,16 @@ def DisconnectTracker(tracker_id, trck_init):
217 if tracker_id == 5: 217 if tracker_id == 5:
218 trck_init = False 218 trck_init = False
219 lib_mode = 'debug' 219 lib_mode = 'debug'
220 - print 'Debug tracker disconnected.' 220 + print('Debug tracker disconnected.')
221 else: 221 else:
222 try: 222 try:
223 trck_init.Close() 223 trck_init.Close()
224 trck_init = False 224 trck_init = False
225 lib_mode = 'wrapper' 225 lib_mode = 'wrapper'
226 - print 'Tracker disconnected.' 226 + print('Tracker disconnected.')
227 except: 227 except:
228 trck_init = True 228 trck_init = True
229 lib_mode = 'error' 229 lib_mode = 'error'
230 - print 'The tracker could not be disconnected.' 230 + print('The tracker could not be disconnected.')
231 231
232 - return trck_init, lib_mode  
233 \ No newline at end of file 232 \ No newline at end of file
  233 + return trck_init, lib_mode
invesalius/data/viewer_slice.py
@@ -105,10 +105,16 @@ class ContourMIPConfig(wx.Panel): @@ -105,10 +105,16 @@ class ContourMIPConfig(wx.Panel):
105 sizer = wx.BoxSizer(wx.HORIZONTAL) 105 sizer = wx.BoxSizer(wx.HORIZONTAL)
106 sizer.Add(txt_mip_size, 0, wx.EXPAND | wx.ALL, 2) 106 sizer.Add(txt_mip_size, 0, wx.EXPAND | wx.ALL, 2)
107 sizer.Add(self.mip_size_spin, 0, wx.EXPAND) 107 sizer.Add(self.mip_size_spin, 0, wx.EXPAND)
108 - sizer.AddSpacer((10, 0)) 108 + try:
  109 + sizer.Add(10, 0)
  110 + except TypeError:
  111 + sizer.Add((10, 0))
109 sizer.Add(self.txt_mip_border, 0, wx.EXPAND | wx.ALL, 2) 112 sizer.Add(self.txt_mip_border, 0, wx.EXPAND | wx.ALL, 2)
110 sizer.Add(self.border_spin, 0, wx.EXPAND) 113 sizer.Add(self.border_spin, 0, wx.EXPAND)
111 - sizer.AddSpacer((10, 0)) 114 + try:
  115 + sizer.Add(10, 0)
  116 + except TypeError:
  117 + sizer.Add((10, 0))
112 sizer.Add(self.inverted, 0, wx.EXPAND) 118 sizer.Add(self.inverted, 0, wx.EXPAND)
113 self.SetSizer(sizer) 119 self.SetSizer(sizer)
114 sizer.Fit(self) 120 sizer.Fit(self)
@@ -206,7 +212,10 @@ class CanvasRendererCTX: @@ -206,7 +212,10 @@ class CanvasRendererCTX:
206 self.alpha = np.zeros((h, w, 1), dtype=np.uint8) 212 self.alpha = np.zeros((h, w, 1), dtype=np.uint8)
207 213
208 self.bitmap = wx.EmptyBitmapRGBA(w, h) 214 self.bitmap = wx.EmptyBitmapRGBA(w, h)
209 - self.image = wx.ImageFromBuffer(w, h, self.rgb, self.alpha) 215 + try:
  216 + self.image = wx.Image(w, h, self.rgb, self.alpha)
  217 + except TypeError:
  218 + self.image = wx.ImageFromBuffer(w, h, self.rgb, self.alpha)
210 219
211 def _resize_canvas(self, w, h): 220 def _resize_canvas(self, w, h):
212 self._array = np.zeros((h, w, 4), dtype=np.uint8) 221 self._array = np.zeros((h, w, 4), dtype=np.uint8)
@@ -218,7 +227,10 @@ class CanvasRendererCTX: @@ -218,7 +227,10 @@ class CanvasRendererCTX:
218 self.alpha = np.zeros((h, w, 1), dtype=np.uint8) 227 self.alpha = np.zeros((h, w, 1), dtype=np.uint8)
219 228
220 self.bitmap = wx.EmptyBitmapRGBA(w, h) 229 self.bitmap = wx.EmptyBitmapRGBA(w, h)
221 - self.image = wx.ImageFromBuffer(w, h, self.rgb, self.alpha) 230 + try:
  231 + self.image = wx.Image(w, h, self.rgb, self.alpha)
  232 + except TypeError:
  233 + self.image = wx.ImageFromBuffer(w, h, self.rgb, self.alpha)
222 234
223 self.modified = True 235 self.modified = True
224 236
@@ -325,7 +337,7 @@ class CanvasRendererCTX: @@ -325,7 +337,7 @@ class CanvasRendererCTX:
325 p0y = -p0y 337 p0y = -p0y
326 p1y = -p1y 338 p1y = -p1y
327 339
328 - pen = wx.Pen(wx.Colour(*colour), width, wx.SOLID) 340 + pen = wx.Pen(wx.Colour(*[int(c) for c in colour]), width, wx.SOLID)
329 pen.SetCap(wx.CAP_BUTT) 341 pen.SetCap(wx.CAP_BUTT)
330 gc.SetPen(pen) 342 gc.SetPen(pen)
331 343
@@ -496,7 +508,7 @@ class CanvasRendererCTX: @@ -496,7 +508,7 @@ class CanvasRendererCTX:
496 if self.gc is None: 508 if self.gc is None:
497 return None 509 return None
498 gc = self.gc 510 gc = self.gc
499 - pen = wx.Pen(wx.Colour(*line_colour), width, wx.SOLID) 511 + pen = wx.Pen(wx.Colour(*[int(c) for c in line_colour]), width, wx.SOLID)
500 gc.SetPen(pen) 512 gc.SetPen(pen)
501 513
502 c = np.array(center) 514 c = np.array(center)
@@ -521,7 +533,7 @@ class CanvasRendererCTX: @@ -521,7 +533,7 @@ class CanvasRendererCTX:
521 ea = a0 533 ea = a0
522 534
523 path = gc.CreatePath() 535 path = gc.CreatePath()
524 - path.AddArc((c[0], c[1]), min(s0, s1), sa, ea) 536 + path.AddArc(float(c[0]), float(c[1]), float(min(s0, s1)), float(sa), float(ea), True)
525 gc.StrokePath(path) 537 gc.StrokePath(path)
526 self._drawn = True 538 self._drawn = True
527 539
@@ -600,7 +612,7 @@ class Viewer(wx.Panel): @@ -600,7 +612,7 @@ class Viewer(wx.Panel):
600 sizer.Add(scroll, 0, wx.EXPAND|wx.GROW) 612 sizer.Add(scroll, 0, wx.EXPAND|wx.GROW)
601 613
602 background_sizer = wx.BoxSizer(wx.VERTICAL) 614 background_sizer = wx.BoxSizer(wx.VERTICAL)
603 - background_sizer.AddSizer(sizer, 1, wx.EXPAND|wx.GROW|wx.ALL, 2) 615 + background_sizer.Add(sizer, 1, wx.EXPAND|wx.GROW|wx.ALL, 2)
604 #background_sizer.Add(self.mip_ctrls, 0, wx.EXPAND|wx.GROW|wx.ALL, 2) 616 #background_sizer.Add(self.mip_ctrls, 0, wx.EXPAND|wx.GROW|wx.ALL, 2)
605 self.SetSizer(background_sizer) 617 self.SetSizer(background_sizer)
606 background_sizer.Fit(self) 618 background_sizer.Fit(self)
@@ -1382,7 +1394,7 @@ class Viewer(wx.Panel): @@ -1382,7 +1394,7 @@ class Viewer(wx.Panel):
1382 number_renderers = self.layout[0] * self.layout[1] 1394 number_renderers = self.layout[0] * self.layout[1]
1383 diff = number_renderers - len(self.slice_data_list) 1395 diff = number_renderers - len(self.slice_data_list)
1384 if diff > 0: 1396 if diff > 0:
1385 - for i in xrange(diff): 1397 + for i in range(diff):
1386 slice_data = self.create_slice_window(imagedata) 1398 slice_data = self.create_slice_window(imagedata)
1387 self.slice_data_list.append(slice_data) 1399 self.slice_data_list.append(slice_data)
1388 elif diff < 0: 1400 elif diff < 0:
@@ -1400,8 +1412,8 @@ class Viewer(wx.Panel): @@ -1400,8 +1412,8 @@ class Viewer(wx.Panel):
1400 w *= proportion_x 1412 w *= proportion_x
1401 h *= proportion_y 1413 h *= proportion_y
1402 n = 0 1414 n = 0
1403 - for j in xrange(self.layout[1]-1, -1, -1):  
1404 - for i in xrange(self.layout[0]): 1415 + for j in range(self.layout[1]-1, -1, -1):
  1416 + for i in range(self.layout[0]):
1405 slice_xi = i*proportion_x 1417 slice_xi = i*proportion_x
1406 slice_xf = (i+1)*proportion_x 1418 slice_xf = (i+1)*proportion_x
1407 slice_yi = j*proportion_y 1419 slice_yi = j*proportion_y
invesalius/data/viewer_volume.py
@@ -507,7 +507,7 @@ class Viewer(wx.Panel): @@ -507,7 +507,7 @@ class Viewer(wx.Panel):
507 """ 507 """
508 self.ball_id = pubsub_evt.data[0] 508 self.ball_id = pubsub_evt.data[0]
509 ballsize = pubsub_evt.data[1] 509 ballsize = pubsub_evt.data[1]
510 - ballcolour = pubsub_evt.data[2] 510 + ballcolour = pubsub_evt.data[2][:3]
511 coord = pubsub_evt.data[3] 511 coord = pubsub_evt.data[3]
512 x, y, z = bases.flip_x(coord) 512 x, y, z = bases.flip_x(coord)
513 513
@@ -1124,7 +1124,7 @@ class Viewer(wx.Panel): @@ -1124,7 +1124,7 @@ class Viewer(wx.Panel):
1124 """ 1124 """
1125 Coil for navigation rendered in volume viewer. 1125 Coil for navigation rendered in volume viewer.
1126 """ 1126 """
1127 - 1127 + filename = utils.decode(filename, const.FS_ENCODE)
1128 if filename: 1128 if filename:
1129 if filename.lower().endswith('.stl'): 1129 if filename.lower().endswith('.stl'):
1130 reader = vtk.vtkSTLReader() 1130 reader = vtk.vtkSTLReader()
@@ -1451,9 +1451,9 @@ class Viewer(wx.Panel): @@ -1451,9 +1451,9 @@ class Viewer(wx.Panel):
1451 if _has_win32api: 1451 if _has_win32api:
1452 utils.touch(filename) 1452 utils.touch(filename)
1453 win_filename = win32api.GetShortPathName(filename) 1453 win_filename = win32api.GetShortPathName(filename)
1454 - self._export_surface(win_filename.encode(const.FS_ENCODE), filetype) 1454 + self._export_surface(win_filename, filetype)
1455 else: 1455 else:
1456 - self._export_surface(filename.encode(const.FS_ENCODE), filetype) 1456 + self._export_surface(filename, filetype)
1457 1457
1458 def _export_surface(self, filename, filetype): 1458 def _export_surface(self, filename, filetype):
1459 fileprefix = filename.split(".")[-2] 1459 fileprefix = filename.split(".")[-2]
@@ -1526,7 +1526,7 @@ class Viewer(wx.Panel): @@ -1526,7 +1526,7 @@ class Viewer(wx.Panel):
1526 1526
1527 def ChangeBackgroundColour(self, pubsub_evt): 1527 def ChangeBackgroundColour(self, pubsub_evt):
1528 colour = pubsub_evt.data 1528 colour = pubsub_evt.data
1529 - self.ren.SetBackground(colour) 1529 + self.ren.SetBackground(colour[:3])
1530 self.UpdateRender() 1530 self.UpdateRender()
1531 1531
1532 def LoadActor(self, pubsub_evt): 1532 def LoadActor(self, pubsub_evt):
invesalius/data/volume.py
@@ -161,22 +161,22 @@ class Volume(): @@ -161,22 +161,22 @@ class Volume():
161 self.LoadVolume() 161 self.LoadVolume()
162 162
163 def OnHideVolume(self, pubsub_evt): 163 def OnHideVolume(self, pubsub_evt):
164 - print 'Hide Volume' 164 + print('Hide Volume')
165 self.volume.SetVisibility(0) 165 self.volume.SetVisibility(0)
166 if (self.plane and self.plane_on): 166 if (self.plane and self.plane_on):
167 self.plane.Disable() 167 self.plane.Disable()
168 Publisher.sendMessage('Render volume viewer') 168 Publisher.sendMessage('Render volume viewer')
169 169
170 def OnShowVolume(self, pubsub_evt = None): 170 def OnShowVolume(self, pubsub_evt = None):
171 - print 'Show volume' 171 + print('Show volume')
172 if self.exist: 172 if self.exist:
173 - print 'Volume exists' 173 + print('Volume exists')
174 self.volume.SetVisibility(1) 174 self.volume.SetVisibility(1)
175 if (self.plane and self.plane_on): 175 if (self.plane and self.plane_on):
176 self.plane.Enable() 176 self.plane.Enable()
177 Publisher.sendMessage('Render volume viewer') 177 Publisher.sendMessage('Render volume viewer')
178 else: 178 else:
179 - print 'Volume doesnt exit' 179 + print('Volume doesnt exit')
180 Publisher.sendMessage('Load raycasting preset', const.RAYCASTING_LABEL) 180 Publisher.sendMessage('Load raycasting preset', const.RAYCASTING_LABEL)
181 self.LoadConfig() 181 self.LoadConfig()
182 self.LoadVolume() 182 self.LoadVolume()
@@ -222,7 +222,7 @@ class Volume(): @@ -222,7 +222,7 @@ class Volume():
222 Publisher.sendMessage('Render volume viewer') 222 Publisher.sendMessage('Render volume viewer')
223 223
224 def OnFlipVolume(self, pubsub_evt): 224 def OnFlipVolume(self, pubsub_evt):
225 - print "Flipping Volume" 225 + print("Flipping Volume")
226 self.loaded_image = False 226 self.loaded_image = False
227 del self.image 227 del self.image
228 self.image = None 228 self.image = None
@@ -360,10 +360,10 @@ class Volume(): @@ -360,10 +360,10 @@ class Volume():
360 r = p['Red'] 360 r = p['Red']
361 g = p['Green'] 361 g = p['Green']
362 b = p['Blue'] 362 b = p['Blue']
363 - colors = zip(r,g,b) 363 + colors = list(zip(r,g,b))
364 else: 364 else:
365 # Grayscale from black to white 365 # Grayscale from black to white
366 - colors = [(i, i, i) for i in xrange(256)] 366 + colors = [(i, i, i) for i in range(256)]
367 367
368 ww = self.config['ww'] 368 ww = self.config['ww']
369 wl = self.TranslateScale(scale, self.config['wl']) 369 wl = self.TranslateScale(scale, self.config['wl'])
invesalius/data/vtk_utils.py
@@ -140,11 +140,10 @@ class Text(object): @@ -140,11 +140,10 @@ class Text(object):
140 # With some encoding in some dicom fields (like name) raises a 140 # With some encoding in some dicom fields (like name) raises a
141 # UnicodeEncodeError because they have non-ascii characters. To avoid 141 # UnicodeEncodeError because they have non-ascii characters. To avoid
142 # that we encode in utf-8. 142 # that we encode in utf-8.
143 -  
144 - if sys.platform == 'win32': 143 + if sys.platform == 'win32':
145 self.mapper.SetInput(value.encode("utf-8")) 144 self.mapper.SetInput(value.encode("utf-8"))
146 else: 145 else:
147 - try: 146 + try:
148 self.mapper.SetInput(value.encode("latin-1")) 147 self.mapper.SetInput(value.encode("latin-1"))
149 except(UnicodeEncodeError): 148 except(UnicodeEncodeError):
150 self.mapper.SetInput(value.encode("utf-8")) 149 self.mapper.SetInput(value.encode("utf-8"))
invesalius/gui/bitmap_preview_panel.py
@@ -218,7 +218,10 @@ class Preview(wx.Panel): @@ -218,7 +218,10 @@ class Preview(wx.Panel):
218 218
219 def OnEnter(self, evt): 219 def OnEnter(self, evt):
220 if not self.select_on: 220 if not self.select_on:
221 - c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE) 221 + try:
  222 + c = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)
  223 + except AttributeError:
  224 + c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE)
222 self.SetBackgroundColour(c) 225 self.SetBackgroundColour(c)
223 226
224 def OnLeave(self, evt): 227 def OnLeave(self, evt):
@@ -257,7 +260,10 @@ class Preview(wx.Panel): @@ -257,7 +260,10 @@ class Preview(wx.Panel):
257 260
258 def Select(self, on=True): 261 def Select(self, on=True):
259 if self.select_on: 262 if self.select_on:
260 - c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT) 263 + try:
  264 + c = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT)
  265 + except AttributeError:
  266 + c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT)
261 else: 267 else:
262 c = (PREVIEW_BACKGROUND) 268 c = (PREVIEW_BACKGROUND)
263 self.SetBackgroundColour(c) 269 self.SetBackgroundColour(c)
@@ -291,10 +297,10 @@ class BitmapPreviewSeries(wx.Panel): @@ -291,10 +297,10 @@ class BitmapPreviewSeries(wx.Panel):
291 self.grid = wx.GridSizer(rows=NROWS, cols=NCOLS, vgap=3, hgap=3) 297 self.grid = wx.GridSizer(rows=NROWS, cols=NCOLS, vgap=3, hgap=3)
292 298
293 sizer = wx.BoxSizer(wx.HORIZONTAL) 299 sizer = wx.BoxSizer(wx.HORIZONTAL)
294 - sizer.AddSizer(self.grid, 1, wx.EXPAND|wx.GROW|wx.ALL, 2) 300 + sizer.Add(self.grid, 1, wx.EXPAND|wx.GROW|wx.ALL, 2)
295 301
296 background_sizer = wx.BoxSizer(wx.HORIZONTAL) 302 background_sizer = wx.BoxSizer(wx.HORIZONTAL)
297 - background_sizer.AddSizer(sizer, 1, wx.EXPAND|wx.GROW|wx.ALL, 2) 303 + background_sizer.Add(sizer, 1, wx.EXPAND|wx.GROW|wx.ALL, 2)
298 background_sizer.Add(scroll, 0, wx.EXPAND|wx.GROW) 304 background_sizer.Add(scroll, 0, wx.EXPAND|wx.GROW)
299 self.SetSizer(background_sizer) 305 self.SetSizer(background_sizer)
300 background_sizer.Fit(self) 306 background_sizer.Fit(self)
@@ -311,8 +317,8 @@ class BitmapPreviewSeries(wx.Panel): @@ -311,8 +317,8 @@ class BitmapPreviewSeries(wx.Panel):
311 317
312 def _Add_Panels_Preview(self): 318 def _Add_Panels_Preview(self):
313 self.previews = [] 319 self.previews = []
314 - for i in xrange(NROWS):  
315 - for j in xrange(NCOLS): 320 + for i in range(NROWS):
  321 + for j in range(NCOLS):
316 p = Preview(self) 322 p = Preview(self)
317 p.Bind(EVT_PREVIEW_CLICK, self.OnSelect) 323 p.Bind(EVT_PREVIEW_CLICK, self.OnSelect)
318 324
@@ -387,7 +393,7 @@ class BitmapPreviewSeries(wx.Panel): @@ -387,7 +393,7 @@ class BitmapPreviewSeries(wx.Panel):
387 initial = self.displayed_position * NCOLS 393 initial = self.displayed_position * NCOLS
388 final = initial + NUM_PREVIEWS 394 final = initial + NUM_PREVIEWS
389 if len(self.files) < final: 395 if len(self.files) < final:
390 - for i in xrange(final-len(self.files)): 396 + for i in range(final-len(self.files)):
391 try: 397 try:
392 self.previews[-i-1].Hide() 398 self.previews[-i-1].Hide()
393 except IndexError: 399 except IndexError:
@@ -396,7 +402,7 @@ class BitmapPreviewSeries(wx.Panel): @@ -396,7 +402,7 @@ class BitmapPreviewSeries(wx.Panel):
396 self.nhidden_last_display = final-len(self.files) 402 self.nhidden_last_display = final-len(self.files)
397 else: 403 else:
398 if self.nhidden_last_display: 404 if self.nhidden_last_display:
399 - for i in xrange(self.nhidden_last_display): 405 + for i in range(self.nhidden_last_display):
400 try: 406 try:
401 self.previews[-i-1].Show() 407 self.previews[-i-1].Show()
402 except IndexError: 408 except IndexError:
@@ -504,7 +510,7 @@ class SingleImagePreview(wx.Panel): @@ -504,7 +510,7 @@ class SingleImagePreview(wx.Panel):
504 maxValue=99, 510 maxValue=99,
505 style=wx.SL_HORIZONTAL|wx.SL_AUTOTICKS) 511 style=wx.SL_HORIZONTAL|wx.SL_AUTOTICKS)
506 slider.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) 512 slider.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
507 - slider.SetTickFreq(1, 1) 513 + slider.SetTickFreq(1)
508 self.slider = slider 514 self.slider = slider
509 515
510 checkbox = wx.CheckBox(self, -1, _("Auto-play")) 516 checkbox = wx.CheckBox(self, -1, _("Auto-play"))
invesalius/gui/data_notebook.py
@@ -29,7 +29,11 @@ except ImportError: @@ -29,7 +29,11 @@ except ImportError:
29 29
30 import wx 30 import wx
31 import wx.grid 31 import wx.grid
32 -import wx.lib.flatnotebook as fnb 32 +try:
  33 + import wx.lib.agw.flatnotebook as fnb
  34 +except ImportError:
  35 + import wx.lib.flatnotebook as fnb
  36 +
33 import wx.lib.platebtn as pbtn 37 import wx.lib.platebtn as pbtn
34 from wx.lib.pubsub import pub as Publisher 38 from wx.lib.pubsub import pub as Publisher
35 39
@@ -40,7 +44,7 @@ import invesalius.gui.widgets.listctrl as listmix @@ -40,7 +44,7 @@ import invesalius.gui.widgets.listctrl as listmix
40 import invesalius.utils as ul 44 import invesalius.utils as ul
41 45
42 46
43 -BTN_NEW, BTN_REMOVE, BTN_DUPLICATE, BTN_OPEN = [wx.NewId() for i in xrange(4)] 47 +BTN_NEW, BTN_REMOVE, BTN_DUPLICATE, BTN_OPEN = [wx.NewId() for i in range(4)]
44 48
45 TYPE = {const.LINEAR: _(u"Linear"), 49 TYPE = {const.LINEAR: _(u"Linear"),
46 const.ANGULAR: _(u"Angular"), 50 const.ANGULAR: _(u"Angular"),
@@ -505,8 +509,8 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): @@ -505,8 +509,8 @@ class MasksListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
505 """ 509 """
506 image = self.image_gray 510 image = self.image_gray
507 new_image = Image.new("RGB", image.size) 511 new_image = Image.new("RGB", image.size)
508 - for x in xrange(image.size[0]):  
509 - for y in xrange(image.size[1]): 512 + for x in range(image.size[0]):
  513 + for y in range(image.size[1]):
510 pixel_colour = [int(i*image.getpixel((x,y))) 514 pixel_colour = [int(i*image.getpixel((x,y)))
511 for i in colour] 515 for i in colour]
512 new_image.putpixel((x,y), tuple(pixel_colour)) 516 new_image.putpixel((x,y), tuple(pixel_colour))
@@ -881,11 +885,17 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): @@ -881,11 +885,17 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
881 self.surface_list_index[index] = image_index 885 self.surface_list_index[index] = image_index
882 886
883 if (index in index_list) and index_list: 887 if (index in index_list) and index_list:
884 - self.UpdateItemInfo(index, name, volume, area, transparency, colour) 888 + try:
  889 + self.UpdateItemInfo(index, name, volume, area, transparency, colour)
  890 + except wx._core.wxAssertionError:
  891 + self.InsertNewItem(index, name, volume, area, transparency, colour)
885 else: 892 else:
886 self.InsertNewItem(index, name, volume, area, transparency, colour) 893 self.InsertNewItem(index, name, volume, area, transparency, colour)
887 else: 894 else:
888 - self.UpdateItemInfo(index, name, volume, area, transparency, colour) 895 + try:
  896 + self.UpdateItemInfo(index, name, volume, area, transparency, colour)
  897 + except wx._core.wxAssertionError:
  898 + self.InsertNewItem(index, name, volume, area, transparency, colour)
889 899
890 def InsertNewItem(self, index=0, label="Surface 1", volume="0 mm3", 900 def InsertNewItem(self, index=0, label="Surface 1", volume="0 mm3",
891 area="0 mm2", transparency="0%%", colour=None): 901 area="0 mm2", transparency="0%%", colour=None):
@@ -899,6 +909,8 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): @@ -899,6 +909,8 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
899 909
900 def UpdateItemInfo(self, index=0, label="Surface 1", volume="0 mm3", 910 def UpdateItemInfo(self, index=0, label="Surface 1", volume="0 mm3",
901 area="0 mm2", transparency="0%%", colour=None): 911 area="0 mm2", transparency="0%%", colour=None):
  912 + print("UpdateItemInfo", index)
  913 + # TODO: Retornar esse codigo
902 self.SetStringItem(index, 1, label, 914 self.SetStringItem(index, 1, label,
903 imageId = self.surface_list_index[index]) 915 imageId = self.surface_list_index[index])
904 self.SetStringItem(index, 2, volume) 916 self.SetStringItem(index, 2, volume)
@@ -913,8 +925,8 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): @@ -913,8 +925,8 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
913 """ 925 """
914 image = self.image_gray 926 image = self.image_gray
915 new_image = Image.new("RGB", image.size) 927 new_image = Image.new("RGB", image.size)
916 - for x in xrange(image.size[0]):  
917 - for y in xrange(image.size[1]): 928 + for x in range(image.size[0]):
  929 + for y in range(image.size[1]):
918 pixel_colour = [int(i*image.getpixel((x,y))) 930 pixel_colour = [int(i*image.getpixel((x,y)))
919 for i in colour] 931 for i in colour]
920 new_image.putpixel((x,y), tuple(pixel_colour)) 932 new_image.putpixel((x,y), tuple(pixel_colour))
@@ -1172,11 +1184,17 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): @@ -1172,11 +1184,17 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
1172 self._list_index[index] = image_index 1184 self._list_index[index] = image_index
1173 1185
1174 if (index in index_list) and index_list: 1186 if (index in index_list) and index_list:
1175 - self.UpdateItemInfo(index, name, colour, location, type_, value) 1187 + try:
  1188 + self.UpdateItemInfo(index, name, colour, location, type_, value)
  1189 + except wx._core.wxAssertionError:
  1190 + self.InsertNewItem(index, name, colour, location, type_, value)
1176 else: 1191 else:
1177 self.InsertNewItem(index, name, colour, location, type_, value) 1192 self.InsertNewItem(index, name, colour, location, type_, value)
1178 else: 1193 else:
1179 - self.UpdateItemInfo(index, name, colour, location, type_, value) 1194 + try:
  1195 + self.UpdateItemInfo(index, name, colour, location, type_, value)
  1196 + except wx._core.wxAssertionError:
  1197 + self.InsertNewItem(index, name, colour, location, type_, value)
1180 1198
1181 1199
1182 1200
@@ -1208,8 +1226,8 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): @@ -1208,8 +1226,8 @@ class MeasuresListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
1208 """ 1226 """
1209 image = self.image_gray 1227 image = self.image_gray
1210 new_image = Image.new("RGB", image.size) 1228 new_image = Image.new("RGB", image.size)
1211 - for x in xrange(image.size[0]):  
1212 - for y in xrange(image.size[1]): 1229 + for x in range(image.size[0]):
  1230 + for y in range(image.size[1]):
1213 pixel_colour = [int(i*image.getpixel((x,y))) 1231 pixel_colour = [int(i*image.getpixel((x,y)))
1214 for i in colour] 1232 for i in colour]
1215 new_image.putpixel((x,y), tuple(pixel_colour)) 1233 new_image.putpixel((x,y), tuple(pixel_colour))
@@ -1301,9 +1319,9 @@ class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): @@ -1301,9 +1319,9 @@ class AnnotationsListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin):
1301 def OnCheckItem(self, index, flag): 1319 def OnCheckItem(self, index, flag):
1302 # TODO: use pubsub to communicate to models 1320 # TODO: use pubsub to communicate to models
1303 if flag: 1321 if flag:
1304 - print "checked, ", index 1322 + print("checked, ", index)
1305 else: 1323 else:
1306 - print "unchecked, ", index 1324 + print("unchecked, ", index)
1307 1325
1308 def InsertNewItem(self, index=0, name="Axial 1", type_="2d", 1326 def InsertNewItem(self, index=0, name="Axial 1", type_="2d",
1309 value="bla", colour=None): 1327 value="bla", colour=None):
invesalius/gui/default_tasks.py
@@ -18,7 +18,10 @@ @@ -18,7 +18,10 @@
18 #-------------------------------------------------------------------------- 18 #--------------------------------------------------------------------------
19 19
20 import wx 20 import wx
21 -import wx.lib.foldpanelbar as fpb 21 +try:
  22 + import wx.lib.agw.foldpanelbar as fpb
  23 +except ModuleNotFoundError:
  24 + import wx.lib.foldpanelbar as fpb
22 from wx.lib.pubsub import pub as Publisher 25 from wx.lib.pubsub import pub as Publisher
23 26
24 import invesalius.constants as const 27 import invesalius.constants as const
@@ -35,7 +38,7 @@ FPB_DEFAULT_STYLE = 2621440 @@ -35,7 +38,7 @@ FPB_DEFAULT_STYLE = 2621440
35 38
36 def GetCollapsedIconData(): 39 def GetCollapsedIconData():
37 return \ 40 return \
38 -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ 41 +b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
39 \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ 42 \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
40 \x00\x01\x8eIDAT8\x8d\xa5\x93-n\xe4@\x10\x85?g\x03\n6lh)\xc4\xd2\x12\xc3\x81\ 43 \x00\x01\x8eIDAT8\x8d\xa5\x93-n\xe4@\x10\x85?g\x03\n6lh)\xc4\xd2\x12\xc3\x81\
41 \xd6\xa2I\x90\x154\xb9\x81\x8f1G\xc8\x11\x16\x86\xcd\xa0\x99F\xb3A\x91\xa1\ 44 \xd6\xa2I\x90\x154\xb9\x81\x8f1G\xc8\x11\x16\x86\xcd\xa0\x99F\xb3A\x91\xa1\
@@ -58,13 +61,13 @@ def GetCollapsedIconBitmap(): @@ -58,13 +61,13 @@ def GetCollapsedIconBitmap():
58 return wx.BitmapFromImage(GetCollapsedIconImage()) 61 return wx.BitmapFromImage(GetCollapsedIconImage())
59 62
60 def GetCollapsedIconImage(): 63 def GetCollapsedIconImage():
61 - import cStringIO  
62 - stream = cStringIO.StringIO(GetCollapsedIconData()) 64 + from io import BytesIO
  65 + stream = BytesIO(GetCollapsedIconData())
63 return wx.ImageFromStream(stream) 66 return wx.ImageFromStream(stream)
64 67
65 def GetExpandedIconData(): 68 def GetExpandedIconData():
66 return \ 69 return \
67 -'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ 70 +b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
68 \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ 71 \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
69 \x00\x01\x9fIDAT8\x8d\x95\x93\xa1\x8e\xdc0\x14EO\xb2\xc4\xd0\xd2\x12\xb7(mI\ 72 \x00\x01\x9fIDAT8\x8d\x95\x93\xa1\x8e\xdc0\x14EO\xb2\xc4\xd0\xd2\x12\xb7(mI\
70 \xa4%V\xd1lQT4[4-\x9a\xfe\xc1\xc2|\xc6\xc2~BY\x83:A3E\xd3\xa0*\xa4\xd2\x90H!\ 73 \xa4%V\xd1lQT4[4-\x9a\xfe\xc1\xc2|\xc6\xc2~BY\x83:A3E\xd3\xa0*\xa4\xd2\x90H!\
@@ -89,8 +92,8 @@ def GetExpandedIconBitmap(): @@ -89,8 +92,8 @@ def GetExpandedIconBitmap():
89 return wx.BitmapFromImage(GetExpandedIconImage()) 92 return wx.BitmapFromImage(GetExpandedIconImage())
90 93
91 def GetExpandedIconImage(): 94 def GetExpandedIconImage():
92 - import cStringIO  
93 - stream = cStringIO.StringIO(GetExpandedIconData()) 95 + from io import BytesIO
  96 + stream = BytesIO(GetExpandedIconData())
94 return wx.ImageFromStream(stream) 97 return wx.ImageFromStream(stream)
95 98
96 99
@@ -239,7 +242,7 @@ class UpperTaskPanel(wx.Panel): @@ -239,7 +242,7 @@ class UpperTaskPanel(wx.Panel):
239 self.overwrite = False 242 self.overwrite = False
240 243
241 session = ses.Session() 244 session = ses.Session()
242 - print "session mode: ", session.mode 245 + print("session mode: ", session.mode)
243 if int(session.mode) == const.MODE_RP: 246 if int(session.mode) == const.MODE_RP:
244 tasks = [(_("Load data"), importer.TaskPanel), 247 tasks = [(_("Load data"), importer.TaskPanel),
245 (_("Select region of interest"), slice_.TaskPanel), 248 (_("Select region of interest"), slice_.TaskPanel),
@@ -253,7 +256,7 @@ class UpperTaskPanel(wx.Panel): @@ -253,7 +256,7 @@ class UpperTaskPanel(wx.Panel):
253 (_("Export data"), exporter.TaskPanel), 256 (_("Export data"), exporter.TaskPanel),
254 (_("Navigation system"), navigator.TaskPanel)] 257 (_("Navigation system"), navigator.TaskPanel)]
255 258
256 - for i in xrange(len(tasks)): 259 + for i in range(len(tasks)):
257 (name, panel) = tasks[i] 260 (name, panel) = tasks[i]
258 # Create panel 261 # Create panel
259 item = fold_panel.AddFoldPanel("%d. %s"%(i+1, name), 262 item = fold_panel.AddFoldPanel("%d. %s"%(i+1, name),
invesalius/gui/default_viewers.py
@@ -306,7 +306,7 @@ import wx.lib.colourselect as csel @@ -306,7 +306,7 @@ import wx.lib.colourselect as csel
306 306
307 import invesalius.constants as const 307 import invesalius.constants as const
308 308
309 -[BUTTON_RAYCASTING, BUTTON_VIEW, BUTTON_SLICE_PLANE, BUTTON_3D_STEREO, BUTTON_TARGET] = [wx.NewId() for num in xrange(5)] 309 +[BUTTON_RAYCASTING, BUTTON_VIEW, BUTTON_SLICE_PLANE, BUTTON_3D_STEREO, BUTTON_TARGET] = [wx.NewId() for num in range(5)]
310 RAYCASTING_TOOLS = wx.NewId() 310 RAYCASTING_TOOLS = wx.NewId()
311 311
312 ID_TO_NAME = {} 312 ID_TO_NAME = {}
invesalius/gui/dialogs.py
@@ -34,7 +34,10 @@ else: @@ -34,7 +34,10 @@ else:
34 34
35 import vtk 35 import vtk
36 import wx 36 import wx
37 -import wx.combo 37 +try:
  38 + from wx.adv import BitmapComboBox
  39 +except ImportError:
  40 + from wx.combo import BitmapComboBox
38 41
39 from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor 42 from vtk.wx.wxVTKRenderWindowInteractor import wxVTKRenderWindowInteractor
40 from wx.lib import masked 43 from wx.lib import masked
@@ -67,11 +70,16 @@ EVT_MASK_SET = wx.PyEventBinder(myEVT_MASK_SET, 1) @@ -67,11 +70,16 @@ EVT_MASK_SET = wx.PyEventBinder(myEVT_MASK_SET, 1)
67 70
68 class NumberDialog(wx.Dialog): 71 class NumberDialog(wx.Dialog):
69 def __init__(self, message, value=0): 72 def __init__(self, message, value=0):
70 - pre = wx.PreDialog()  
71 - pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize,  
72 - pos=wx.DefaultPosition,  
73 - style=wx.DEFAULT_DIALOG_STYLE)  
74 - self.PostCreate(pre) 73 + try:
  74 + pre = wx.PreDialog()
  75 + pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize,
  76 + pos=wx.DefaultPosition,
  77 + style=wx.DEFAULT_DIALOG_STYLE)
  78 + self.PostCreate(pre)
  79 + except AttributeError:
  80 + wx.Dialog.__init__(self, None, -1, "InVesalius 3", size=wx.DefaultSize,
  81 + pos=wx.DefaultPosition,
  82 + style=wx.DEFAULT_DIALOG_STYLE)
75 83
76 # Static text which contains message to user 84 # Static text which contains message to user
77 label = wx.StaticText(self, -1, message) 85 label = wx.StaticText(self, -1, message)
@@ -117,11 +125,16 @@ class NumberDialog(wx.Dialog): @@ -117,11 +125,16 @@ class NumberDialog(wx.Dialog):
117 class ResizeImageDialog(wx.Dialog): 125 class ResizeImageDialog(wx.Dialog):
118 126
119 def __init__(self):#, message, value=0): 127 def __init__(self):#, message, value=0):
120 - pre = self.pre = wx.PreDialog()  
121 - pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize,  
122 - pos=wx.DefaultPosition,  
123 - style=wx.DEFAULT_DIALOG_STYLE)  
124 - self.PostCreate(pre) 128 + try:
  129 + pre = self.pre = wx.PreDialog()
  130 + pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize,
  131 + pos=wx.DefaultPosition,
  132 + style=wx.DEFAULT_DIALOG_STYLE)
  133 + self.PostCreate(pre)
  134 + except AttributeError:
  135 + wx.Dialog.__init__(self, None, -1, "InVesalius 3", size=wx.DefaultSize,
  136 + pos=wx.DefaultPosition,
  137 + style=wx.DEFAULT_DIALOG_STYLE)
125 138
126 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.")) 139 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."))
127 icon = wx.ArtProvider.GetBitmap(wx.ART_WARNING, wx.ART_MESSAGE_BOX, (32,32)) 140 icon = wx.ArtProvider.GetBitmap(wx.ART_WARNING, wx.ART_MESSAGE_BOX, (32,32))
@@ -149,12 +162,12 @@ class ResizeImageDialog(wx.Dialog): @@ -149,12 +162,12 @@ class ResizeImageDialog(wx.Dialog):
149 162
150 sizer_itens = wx.BoxSizer(wx.VERTICAL) 163 sizer_itens = wx.BoxSizer(wx.VERTICAL)
151 sizer_itens.Add(lbl_message, 0, wx.EXPAND|wx.ALL, 5) 164 sizer_itens.Add(lbl_message, 0, wx.EXPAND|wx.ALL, 5)
152 - sizer_itens.AddSizer(sizer_percent, 0, wx.EXPAND|wx.ALL, 5) 165 + sizer_itens.Add(sizer_percent, 0, wx.EXPAND|wx.ALL, 5)
153 sizer_itens.Add(btn_sizer, 0, wx.EXPAND|wx.ALL, 5) 166 sizer_itens.Add(btn_sizer, 0, wx.EXPAND|wx.ALL, 5)
154 167
155 sizer_general = wx.BoxSizer(wx.HORIZONTAL) 168 sizer_general = wx.BoxSizer(wx.HORIZONTAL)
156 sizer_general.Add(bmp, 0, wx.ALIGN_CENTRE|wx.ALL, 10) 169 sizer_general.Add(bmp, 0, wx.ALIGN_CENTRE|wx.ALL, 10)
157 - sizer_general.AddSizer(sizer_itens, 0, wx.ALL , 5) 170 + sizer_general.Add(sizer_itens, 0, wx.ALL , 5)
158 171
159 #self.SetAutoLayout(True) 172 #self.SetAutoLayout(True)
160 self.SetSizer(sizer_general) 173 self.SetSizer(sizer_general)
@@ -169,7 +182,7 @@ class ResizeImageDialog(wx.Dialog): @@ -169,7 +182,7 @@ class ResizeImageDialog(wx.Dialog):
169 return self.num_ctrl_porcent.GetValue() 182 return self.num_ctrl_porcent.GetValue()
170 183
171 def Close(self): 184 def Close(self):
172 - self.pre.Destroy() 185 + self.Destroy()
173 186
174 def ShowNumberDialog(message, value=0): 187 def ShowNumberDialog(message, value=0):
175 dlg = NumberDialog(message, value) 188 dlg = NumberDialog(message, value)
@@ -465,7 +478,7 @@ def ShowSaveMarkersDialog(default_filename=None): @@ -465,7 +478,7 @@ def ShowSaveMarkersDialog(default_filename=None):
465 "", # last used directory 478 "", # last used directory
466 default_filename, 479 default_filename,
467 _("Markers files (*.mks)|*.mks"), 480 _("Markers files (*.mks)|*.mks"),
468 - wx.SAVE | wx.OVERWRITE_PROMPT) 481 + wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
469 # dlg.SetFilterIndex(0) # default is VTI 482 # dlg.SetFilterIndex(0) # default is VTI
470 483
471 filename = None 484 filename = None
@@ -495,7 +508,7 @@ def ShowSaveCoordsDialog(default_filename=None): @@ -495,7 +508,7 @@ def ShowSaveCoordsDialog(default_filename=None):
495 "", # last used directory 508 "", # last used directory
496 default_filename, 509 default_filename,
497 _("Coordinates files (*.csv)|*.csv"), 510 _("Coordinates files (*.csv)|*.csv"),
498 - wx.SAVE | wx.OVERWRITE_PROMPT) 511 + wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
499 # dlg.SetFilterIndex(0) # default is VTI 512 # dlg.SetFilterIndex(0) # default is VTI
500 513
501 filename = None 514 filename = None
@@ -526,7 +539,7 @@ def ShowLoadMarkersDialog(): @@ -526,7 +539,7 @@ def ShowLoadMarkersDialog():
526 defaultDir="", 539 defaultDir="",
527 defaultFile="", 540 defaultFile="",
528 wildcard=_("Markers files (*.mks)|*.mks"), 541 wildcard=_("Markers files (*.mks)|*.mks"),
529 - style=wx.OPEN|wx.CHANGE_DIR) 542 + style=wx.FD_OPEN|wx.FD_CHANGE_DIR)
530 543
531 # inv3 filter is default 544 # inv3 filter is default
532 dlg.SetFilterIndex(0) 545 dlg.SetFilterIndex(0)
@@ -555,7 +568,7 @@ def ShowSaveRegistrationDialog(default_filename=None): @@ -555,7 +568,7 @@ def ShowSaveRegistrationDialog(default_filename=None):
555 "", # last used directory 568 "", # last used directory
556 default_filename, 569 default_filename,
557 _("Registration files (*.obr)|*.obr"), 570 _("Registration files (*.obr)|*.obr"),
558 - wx.SAVE | wx.OVERWRITE_PROMPT) 571 + wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
559 # dlg.SetFilterIndex(0) # default is VTI 572 # dlg.SetFilterIndex(0) # default is VTI
560 573
561 filename = None 574 filename = None
@@ -586,7 +599,7 @@ def ShowLoadRegistrationDialog(): @@ -586,7 +599,7 @@ def ShowLoadRegistrationDialog():
586 defaultDir="", 599 defaultDir="",
587 defaultFile="", 600 defaultFile="",
588 wildcard=_("Registration files (*.obr)|*.obr"), 601 wildcard=_("Registration files (*.obr)|*.obr"),
589 - style=wx.OPEN|wx.CHANGE_DIR) 602 + style=wx.FD_OPEN|wx.FD_CHANGE_DIR)
590 603
591 # inv3 filter is default 604 # inv3 filter is default
592 dlg.SetFilterIndex(0) 605 dlg.SetFilterIndex(0)
@@ -610,10 +623,14 @@ def ShowLoadRegistrationDialog(): @@ -610,10 +623,14 @@ def ShowLoadRegistrationDialog():
610 623
611 class MessageDialog(wx.Dialog): 624 class MessageDialog(wx.Dialog):
612 def __init__(self, message): 625 def __init__(self, message):
613 - pre = wx.PreDialog()  
614 - pre.Create(None, -1, "InVesalius 3", size=(360, 370), pos=wx.DefaultPosition,  
615 - style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)  
616 - self.PostCreate(pre) 626 + try:
  627 + pre = wx.PreDialog()
  628 + pre.Create(None, -1, "InVesalius 3", size=(360, 370), pos=wx.DefaultPosition,
  629 + style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)
  630 + self.PostCreate(pre)
  631 + except AttributeError:
  632 + wx.Dialog.__init__(self, None, -1, "InVesalius 3", size=(360, 370), pos=wx.DefaultPosition,
  633 + style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)
617 634
618 # Static text which contains message to user 635 # Static text which contains message to user
619 label = wx.StaticText(self, -1, message) 636 label = wx.StaticText(self, -1, message)
@@ -652,10 +669,14 @@ class UpdateMessageDialog(wx.Dialog): @@ -652,10 +669,14 @@ class UpdateMessageDialog(wx.Dialog):
652 title=_("Invesalius Update") 669 title=_("Invesalius Update")
653 self.url = url 670 self.url = url
654 671
655 - pre = wx.PreDialog()  
656 - pre.Create(None, -1, title, size=(360, 370), pos=wx.DefaultPosition,  
657 - style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)  
658 - self.PostCreate(pre) 672 + try:
  673 + pre = wx.PreDialog()
  674 + pre.Create(None, -1, title, size=(360, 370), pos=wx.DefaultPosition,
  675 + style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)
  676 + self.PostCreate(pre)
  677 + except AttributeError:
  678 + wx.Dialog.__init__(self, None, -1, title, size=(360, 370), pos=wx.DefaultPosition,
  679 + style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)
659 680
660 # Static text which contains message to user 681 # Static text which contains message to user
661 label = wx.StaticText(self, -1, msg) 682 label = wx.StaticText(self, -1, msg)
@@ -993,18 +1014,22 @@ class NewMask(wx.Dialog): @@ -993,18 +1014,22 @@ class NewMask(wx.Dialog):
993 import invesalius.data.mask as mask 1014 import invesalius.data.mask as mask
994 import invesalius.project as prj 1015 import invesalius.project as prj
995 1016
996 - # Instead of calling wx.Dialog.__init__ we precreate the dialog  
997 - # so we can set an extra style that must be set before  
998 - # creation, and then we create the GUI object using the Create  
999 - # method.  
1000 - pre = wx.PreDialog()  
1001 - pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)  
1002 - pre.Create(parent, ID, title, pos, (500,300), style) 1017 + try:
  1018 + # Instead of calling wx.Dialog.__init__ we precreate the dialog
  1019 + # so we can set an extra style that must be set before
  1020 + # creation, and then we create the GUI object using the Create
  1021 + # method.
  1022 + pre = wx.PreDialog()
  1023 + pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
  1024 + pre.Create(parent, ID, title, pos, (500,300), style)
  1025 + # This next step is the most important, it turns this Python
  1026 + # object into the real wrapper of the dialog (instead of pre)
  1027 + # as far as the wxPython extension is concerned.
  1028 + self.PostCreate(pre)
  1029 + except AttributeError:
  1030 + wx.Dialog.__init__(self, parent, ID, title, pos, (500,300), style)
  1031 + self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
1003 1032
1004 - # This next step is the most important, it turns this Python  
1005 - # object into the real wrapper of the dialog (instead of pre)  
1006 - # as far as the wxPython extension is concerned.  
1007 - self.PostCreate(pre)  
1008 1033
1009 self.CenterOnScreen() 1034 self.CenterOnScreen()
1010 1035
@@ -1031,8 +1056,7 @@ class NewMask(wx.Dialog): @@ -1031,8 +1056,7 @@ class NewMask(wx.Dialog):
1031 1056
1032 # Retrieve existing masks 1057 # Retrieve existing masks
1033 project = prj.Project() 1058 project = prj.Project()
1034 - thresh_list = project.threshold_modes.keys()  
1035 - thresh_list.sort() 1059 + thresh_list = sorted(project.threshold_modes.keys())
1036 default_index = thresh_list.index(_("Bone")) 1060 default_index = thresh_list.index(_("Bone"))
1037 self.thresh_list = thresh_list 1061 self.thresh_list = thresh_list
1038 1062
@@ -1285,18 +1309,22 @@ class NewSurfaceDialog(wx.Dialog): @@ -1285,18 +1309,22 @@ class NewSurfaceDialog(wx.Dialog):
1285 import invesalius.data.surface as surface 1309 import invesalius.data.surface as surface
1286 import invesalius.project as prj 1310 import invesalius.project as prj
1287 1311
1288 - # Instead of calling wx.Dialog.__init__ we precreate the dialog  
1289 - # so we can set an extra style that must be set before  
1290 - # creation, and then we create the GUI object using the Create  
1291 - # method.  
1292 - pre = wx.PreDialog()  
1293 - pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)  
1294 - pre.Create(parent, ID, title, pos, (500,300), style)  
1295 -  
1296 - # This next step is the most important, it turns this Python  
1297 - # object into the real wrapper of the dialog (instead of pre)  
1298 - # as far as the wxPython extension is concerned.  
1299 - self.PostCreate(pre) 1312 + try:
  1313 + # Instead of calling wx.Dialog.__init__ we precreate the dialog
  1314 + # so we can set an extra style that must be set before
  1315 + # creation, and then we create the GUI object using the Create
  1316 + # method.
  1317 + pre = wx.PreDialog()
  1318 + pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
  1319 + pre.Create(parent, ID, title, pos, (500,300), style)
  1320 +
  1321 + # This next step is the most important, it turns this Python
  1322 + # object into the real wrapper of the dialog (instead of pre)
  1323 + # as far as the wxPython extension is concerned.
  1324 + self.PostCreate(pre)
  1325 + except AttributeError:
  1326 + wx.Dialog.__init__(self, parent, ID, title, pos, (500,300), style)
  1327 + self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
1300 1328
1301 self.CenterOnScreen() 1329 self.CenterOnScreen()
1302 1330
@@ -1323,8 +1351,7 @@ class NewSurfaceDialog(wx.Dialog): @@ -1323,8 +1351,7 @@ class NewSurfaceDialog(wx.Dialog):
1323 1351
1324 # Retrieve existing masks 1352 # Retrieve existing masks
1325 project = prj.Project() 1353 project = prj.Project()
1326 - index_list = project.mask_dict.keys()  
1327 - index_list.sort() 1354 + index_list = sorted(project.mask_dict.keys())
1328 self.mask_list = [project.mask_dict[index].name for index in index_list] 1355 self.mask_list = [project.mask_dict[index].name for index in index_list]
1329 1356
1330 1357
@@ -1498,18 +1525,24 @@ class SurfaceCreationDialog(wx.Dialog): @@ -1498,18 +1525,24 @@ class SurfaceCreationDialog(wx.Dialog):
1498 # so we can set an extra style that must be set before 1525 # so we can set an extra style that must be set before
1499 # creation, and then we create the GUI object using the Create 1526 # creation, and then we create the GUI object using the Create
1500 # method. 1527 # method.
1501 - pre = wx.PreDialog()  
1502 - pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)  
1503 - pre.Create(parent, ID, title, pos, (500,300), style)  
1504 -  
1505 - # This extra style can be set after the UI object has been created.  
1506 - if 'wxMac' in wx.PlatformInfo and useMetal:  
1507 - self.SetExtraStyle(wx.DIALOG_EX_METAL)  
1508 -  
1509 - # This next step is the most important, it turns this Python  
1510 - # object into the real wrapper of the dialog (instead of pre)  
1511 - # as far as the wxPython extension is concerned.  
1512 - self.PostCreate(pre) 1528 + try:
  1529 + pre = wx.PreDialog()
  1530 + pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
  1531 + pre.Create(parent, ID, title, pos, (500,300), style)
  1532 +
  1533 + # This extra style can be set after the UI object has been created.
  1534 + if 'wxMac' in wx.PlatformInfo and useMetal:
  1535 + self.SetExtraStyle(wx.DIALOG_EX_METAL)
  1536 +
  1537 + # This next step is the most important, it turns this Python
  1538 + # object into the real wrapper of the dialog (instead of pre)
  1539 + # as far as the wxPython extension is concerned.
  1540 + self.PostCreate(pre)
  1541 + except AttributeError:
  1542 + wx.Dialog.__init__(self, parent, ID, title, pos, size, style)
  1543 + self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
  1544 + if 'wxMac' in wx.PlatformInfo and useMetal:
  1545 + self.SetExtraStyle(wx.DIALOG_EX_METAL)
1513 1546
1514 self.CenterOnScreen() 1547 self.CenterOnScreen()
1515 1548
@@ -1583,8 +1616,7 @@ class SurfaceCreationOptionsPanel(wx.Panel): @@ -1583,8 +1616,7 @@ class SurfaceCreationOptionsPanel(wx.Panel):
1583 #Retrieve existing masks 1616 #Retrieve existing masks
1584 project = prj.Project() 1617 project = prj.Project()
1585 index_list = project.mask_dict.keys() 1618 index_list = project.mask_dict.keys()
1586 - index_list.sort()  
1587 - self.mask_list = [project.mask_dict[index].name for index in index_list] 1619 + self.mask_list = [project.mask_dict[index].name for index in sorted(index_list)]
1588 1620
1589 active_mask = slc.Slice().current_mask.index 1621 active_mask = slc.Slice().current_mask.index
1590 #active_mask = len(self.mask_list)-1 1622 #active_mask = len(self.mask_list)-1
@@ -1810,9 +1842,12 @@ class SurfaceMethodPanel(wx.Panel): @@ -1810,9 +1842,12 @@ class SurfaceMethodPanel(wx.Panel):
1810 1842
1811 class ClutImagedataDialog(wx.Dialog): 1843 class ClutImagedataDialog(wx.Dialog):
1812 def __init__(self, histogram, init, end, nodes=None): 1844 def __init__(self, histogram, init, end, nodes=None):
1813 - pre = wx.PreDialog()  
1814 - pre.Create(wx.GetApp().GetTopWindow(), -1, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)  
1815 - self.PostCreate(pre) 1845 + try:
  1846 + pre = wx.PreDialog()
  1847 + pre.Create(wx.GetApp().GetTopWindow(), -1, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
  1848 + self.PostCreate(pre)
  1849 + except AttributeError:
  1850 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
1816 1851
1817 self.histogram = histogram 1852 self.histogram = histogram
1818 self.init = init 1853 self.init = init
@@ -1910,10 +1945,13 @@ class WatershedOptionsPanel(wx.Panel): @@ -1910,10 +1945,13 @@ class WatershedOptionsPanel(wx.Panel):
1910 1945
1911 1946
1912 class WatershedOptionsDialog(wx.Dialog): 1947 class WatershedOptionsDialog(wx.Dialog):
1913 - def __init__(self, config):  
1914 - pre = wx.PreDialog()  
1915 - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u'Watershed'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)  
1916 - self.PostCreate(pre) 1948 + def __init__(self, config, ID=-1, title=_(u'Watershed'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT):
  1949 + try:
  1950 + pre = wx.PreDialog()
  1951 + pre.Create(wx.GetApp().GetTopWindow(), ID, title=title, style=style)
  1952 + self.PostCreate(pre)
  1953 + except AttributeError:
  1954 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style)
1917 1955
1918 self.config = config 1956 self.config = config
1919 1957
@@ -1951,10 +1989,13 @@ class WatershedOptionsDialog(wx.Dialog): @@ -1951,10 +1989,13 @@ class WatershedOptionsDialog(wx.Dialog):
1951 evt.Skip() 1989 evt.Skip()
1952 1990
1953 class MaskBooleanDialog(wx.Dialog): 1991 class MaskBooleanDialog(wx.Dialog):
1954 - def __init__(self, masks):  
1955 - pre = wx.PreDialog()  
1956 - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Boolean operations"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)  
1957 - self.PostCreate(pre) 1992 + def __init__(self, masks, ID=-1, title=_(u"Boolean operations"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP):
  1993 + try:
  1994 + pre = wx.PreDialog()
  1995 + pre.Create(wx.GetApp().GetTopWindow(), ID, title=title, style=style)
  1996 + self.PostCreate(pre)
  1997 + except AttributeError:
  1998 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style)
1958 1999
1959 self._init_gui(masks) 2000 self._init_gui(masks)
1960 self.CenterOnScreen() 2001 self.CenterOnScreen()
@@ -1980,7 +2021,7 @@ class MaskBooleanDialog(wx.Dialog): @@ -1980,7 +2021,7 @@ class MaskBooleanDialog(wx.Dialog):
1980 (_(u"Difference"), const.BOOLEAN_DIFF, 'bool_difference.png'), 2021 (_(u"Difference"), const.BOOLEAN_DIFF, 'bool_difference.png'),
1981 (_(u"Intersection"), const.BOOLEAN_AND, 'bool_intersection.png'), 2022 (_(u"Intersection"), const.BOOLEAN_AND, 'bool_intersection.png'),
1982 (_(u"Exclusive disjunction"), const.BOOLEAN_XOR, 'bool_disjunction.png')) 2023 (_(u"Exclusive disjunction"), const.BOOLEAN_XOR, 'bool_disjunction.png'))
1983 - self.op_boolean = wx.combo.BitmapComboBox(self, -1, op_choices[0][0], choices=[]) 2024 + self.op_boolean = BitmapComboBox(self, -1, op_choices[0][0], choices=[])
1984 2025
1985 for n, i, f in op_choices: 2026 for n, i, f in op_choices:
1986 bmp = wx.Bitmap(os.path.join(icon_folder, f), wx.BITMAP_TYPE_PNG) 2027 bmp = wx.Bitmap(os.path.join(icon_folder, f), wx.BITMAP_TYPE_PNG)
@@ -2031,10 +2072,13 @@ class MaskBooleanDialog(wx.Dialog): @@ -2031,10 +2072,13 @@ class MaskBooleanDialog(wx.Dialog):
2031 2072
2032 2073
2033 class ReorientImageDialog(wx.Dialog): 2074 class ReorientImageDialog(wx.Dialog):
2034 - def __init__(self):  
2035 - pre = wx.PreDialog()  
2036 - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u'Image reorientation'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)  
2037 - self.PostCreate(pre) 2075 + def __init__(self, ID=-1, title=_(u'Image reorientation'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT):
  2076 + try:
  2077 + pre = wx.PreDialog()
  2078 + pre.Create(wx.GetApp().GetTopWindow(), ID, title=title, style=style)
  2079 + self.PostCreate(pre)
  2080 + except AttributeError:
  2081 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style)
2038 2082
2039 self._closed = False 2083 self._closed = False
2040 2084
@@ -2149,22 +2193,25 @@ class ImportBitmapParameters(wx.Dialog): @@ -2149,22 +2193,25 @@ class ImportBitmapParameters(wx.Dialog):
2149 from os import sys 2193 from os import sys
2150 2194
2151 def __init__(self): 2195 def __init__(self):
2152 - pre = wx.PreDialog()  
2153 -  
2154 if sys.platform == 'win32': 2196 if sys.platform == 'win32':
2155 size=wx.Size(380,180) 2197 size=wx.Size(380,180)
2156 else: 2198 else:
2157 size=wx.Size(380,210) 2199 size=wx.Size(380,210)
2158 2200
2159 - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Create project from bitmap"),size=size,\  
2160 - style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP) 2201 + try:
  2202 + pre = wx.PreDialog()
  2203 + pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Create project from bitmap"),size=size,
  2204 + style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)
  2205 + self.PostCreate(pre)
  2206 + except AttributeError:
  2207 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1,
  2208 + _(u"Create project from bitmap"),
  2209 + size=size,
  2210 + style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)
2161 2211
2162 self.interval = 0 2212 self.interval = 0
2163 -  
2164 - self.PostCreate(pre)  
2165 2213
2166 self._init_gui() 2214 self._init_gui()
2167 -  
2168 self.bind_evts() 2215 self.bind_evts()
2169 self.CenterOnScreen() 2216 self.CenterOnScreen()
2170 2217
@@ -2195,13 +2242,19 @@ class ImportBitmapParameters(wx.Dialog): @@ -2195,13 +2242,19 @@ class ImportBitmapParameters(wx.Dialog):
2195 2242
2196 gbs.Add(stx_name, (0,0), flag=flag_labels) 2243 gbs.Add(stx_name, (0,0), flag=flag_labels)
2197 gbs.Add(tx_name, (0,1)) 2244 gbs.Add(tx_name, (0,1))
2198 - gbs.AddStretchSpacer((1,0)) 2245 + try:
  2246 + gbs.Add(0, 0, (1,0))
  2247 + except TypeError:
  2248 + gbs.AddStretchSpacer((1,0))
2199 2249
2200 gbs.Add(stx_orientation, (2,0), flag=flag_labels) 2250 gbs.Add(stx_orientation, (2,0), flag=flag_labels)
2201 gbs.Add(cb_orientation, (2,1)) 2251 gbs.Add(cb_orientation, (2,1))
2202 2252
2203 gbs.Add(stx_spacing, (3,0)) 2253 gbs.Add(stx_spacing, (3,0))
2204 - gbs.AddStretchSpacer((4,0)) 2254 + try:
  2255 + gbs.Add(0, 0, (4,0))
  2256 + except TypeError:
  2257 + gbs.AddStretchSpacer((4,0))
2205 2258
2206 #--- spacing -------------- 2259 #--- spacing --------------
2207 gbs_spacing = wx.GridBagSizer(2, 6) 2260 gbs_spacing = wx.GridBagSizer(2, 6)
@@ -2251,17 +2304,23 @@ class ImportBitmapParameters(wx.Dialog): @@ -2251,17 +2304,23 @@ class ImportBitmapParameters(wx.Dialog):
2251 2304
2252 btn_cancel = wx.Button(p, wx.ID_CANCEL) 2305 btn_cancel = wx.Button(p, wx.ID_CANCEL)
2253 2306
2254 - gbs_button.AddStretchSpacer((0,2)) 2307 + try:
  2308 + gbs_button.Add(0, 0, (0,2))
  2309 + except TypeError:
  2310 + gbs_button.AddStretchSpacer((0,2))
2255 gbs_button.Add(btn_cancel, (1,2)) 2311 gbs_button.Add(btn_cancel, (1,2))
2256 gbs_button.Add(btn_ok, (1,3)) 2312 gbs_button.Add(btn_ok, (1,3))
2257 2313
2258 - gbs_principal.AddSizer(gbs, (0,0), flag = wx.ALL|wx.EXPAND)  
2259 - gbs_principal.AddSizer(gbs_spacing, (1,0), flag=wx.ALL|wx.EXPAND)  
2260 - gbs_principal.AddStretchSpacer((2,0))  
2261 - gbs_principal.AddSizer(gbs_button, (3,0), flag = wx.ALIGN_RIGHT) 2314 + gbs_principal.Add(gbs, (0,0), flag = wx.ALL|wx.EXPAND)
  2315 + gbs_principal.Add(gbs_spacing, (1,0), flag=wx.ALL|wx.EXPAND)
  2316 + try:
  2317 + gbs_principal.Add(0, 0, (2,0))
  2318 + except TypeError:
  2319 + gbs_principal.AddStretchSpacer((2,0))
  2320 + gbs_principal.Add(gbs_button, (3,0), flag = wx.ALIGN_RIGHT)
2262 2321
2263 box = wx.BoxSizer() 2322 box = wx.BoxSizer()
2264 - box.AddSizer(gbs_principal, 1, wx.ALL|wx.EXPAND, 10) 2323 + box.Add(gbs_principal, 1, wx.ALL|wx.EXPAND, 10)
2265 2324
2266 p.SetSizer(box) 2325 p.SetSizer(box)
2267 box.Fit(self) 2326 box.Fit(self)
@@ -2312,10 +2371,16 @@ class PanelTargeFFill(wx.Panel): @@ -2312,10 +2371,16 @@ class PanelTargeFFill(wx.Panel):
2312 2371
2313 sizer = wx.GridBagSizer(5, 5) 2372 sizer = wx.GridBagSizer(5, 5)
2314 2373
2315 - sizer.AddStretchSpacer((0, 0)) 2374 + try:
  2375 + sizer.Add(0, 0, (0, 0))
  2376 + except TypeError:
  2377 + sizer.AddStretchSpacer((0, 0))
2316 sizer.Add(self.target_2d, (1, 0), (1, 6), flag=wx.LEFT, border=5) 2378 sizer.Add(self.target_2d, (1, 0), (1, 6), flag=wx.LEFT, border=5)
2317 sizer.Add(self.target_3d, (2, 0), (1, 6), flag=wx.LEFT, border=5) 2379 sizer.Add(self.target_3d, (2, 0), (1, 6), flag=wx.LEFT, border=5)
2318 - sizer.AddStretchSpacer((3, 0)) 2380 + try:
  2381 + sizer.Add(0, 0, (3, 0))
  2382 + except TypeError:
  2383 + sizer.AddStretchSpacer((3, 0))
2319 2384
2320 self.SetSizer(sizer) 2385 self.SetSizer(sizer)
2321 sizer.Fit(self) 2386 sizer.Fit(self)
@@ -2332,11 +2397,17 @@ class Panel2DConnectivity(wx.Panel): @@ -2332,11 +2397,17 @@ class Panel2DConnectivity(wx.Panel):
2332 2397
2333 sizer = wx.GridBagSizer(5, 5) 2398 sizer = wx.GridBagSizer(5, 5)
2334 2399
2335 - sizer.AddStretchSpacer((0, 0)) 2400 + try:
  2401 + sizer.Add(0, 0, (0, 0))
  2402 + except TypeError:
  2403 + sizer.AddStretchSpacer((0, 0))
2336 sizer.Add(wx.StaticText(self, -1, _(u"2D Connectivity")), (1, 0), (1, 6), flag=wx.LEFT, border=5) 2404 sizer.Add(wx.StaticText(self, -1, _(u"2D Connectivity")), (1, 0), (1, 6), flag=wx.LEFT, border=5)
2337 sizer.Add(self.conect2D_4, (2, 0), flag=wx.LEFT, border=7) 2405 sizer.Add(self.conect2D_4, (2, 0), flag=wx.LEFT, border=7)
2338 sizer.Add(self.conect2D_8, (2, 1), flag=wx.LEFT, border=7) 2406 sizer.Add(self.conect2D_8, (2, 1), flag=wx.LEFT, border=7)
2339 - sizer.AddStretchSpacer((3, 0)) 2407 + try:
  2408 + sizer.Add(0, 0, (3, 0))
  2409 + except TypeError:
  2410 + sizer.AddStretchSpacer((3, 0))
2340 2411
2341 if show_orientation: 2412 if show_orientation:
2342 self.cmb_orientation = wx.ComboBox(self, -1, choices=(_(u"Axial"), _(u"Coronal"), _(u"Sagital")), style=wx.CB_READONLY) 2413 self.cmb_orientation = wx.ComboBox(self, -1, choices=(_(u"Axial"), _(u"Coronal"), _(u"Sagital")), style=wx.CB_READONLY)
@@ -2344,7 +2415,10 @@ class Panel2DConnectivity(wx.Panel): @@ -2344,7 +2415,10 @@ class Panel2DConnectivity(wx.Panel):
2344 2415
2345 sizer.Add(wx.StaticText(self, -1, _(u"Orientation")), (4, 0), (1, 6), flag=wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5) 2416 sizer.Add(wx.StaticText(self, -1, _(u"Orientation")), (4, 0), (1, 6), flag=wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
2346 sizer.Add(self.cmb_orientation, (5, 0), (1, 10), flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=7) 2417 sizer.Add(self.cmb_orientation, (5, 0), (1, 10), flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=7)
2347 - sizer.AddStretchSpacer((6, 0)) 2418 + try:
  2419 + sizer.Add(0, 0, (6, 0))
  2420 + except TypeError:
  2421 + sizer.AddStretchSpacer((6, 0))
2348 2422
2349 self.SetSizer(sizer) 2423 self.SetSizer(sizer)
2350 sizer.Fit(self) 2424 sizer.Fit(self)
@@ -2378,12 +2452,18 @@ class Panel3DConnectivity(wx.Panel): @@ -2378,12 +2452,18 @@ class Panel3DConnectivity(wx.Panel):
2378 2452
2379 sizer = wx.GridBagSizer(5, 5) 2453 sizer = wx.GridBagSizer(5, 5)
2380 2454
2381 - sizer.AddStretchSpacer((0, 0)) 2455 + try:
  2456 + sizer.Add(0, 0, (0, 0))
  2457 + except TypeError:
  2458 + sizer.AddStretchSpacer((0, 0))
2382 sizer.Add(wx.StaticText(self, -1, _(u"3D Connectivity")), (1, 0), (1, 6), flag=wx.LEFT, border=5) 2459 sizer.Add(wx.StaticText(self, -1, _(u"3D Connectivity")), (1, 0), (1, 6), flag=wx.LEFT, border=5)
2383 sizer.Add(self.conect3D_6, (2, 0), flag=wx.LEFT, border=9) 2460 sizer.Add(self.conect3D_6, (2, 0), flag=wx.LEFT, border=9)
2384 sizer.Add(self.conect3D_18, (2, 1), flag=wx.LEFT, border=9) 2461 sizer.Add(self.conect3D_18, (2, 1), flag=wx.LEFT, border=9)
2385 sizer.Add(self.conect3D_26, (2, 2), flag=wx.LEFT, border=9) 2462 sizer.Add(self.conect3D_26, (2, 2), flag=wx.LEFT, border=9)
2386 - sizer.AddStretchSpacer((3, 0)) 2463 + try:
  2464 + sizer.Add(0, 0, (3, 0))
  2465 + except TypeError:
  2466 + sizer.AddStretchSpacer((3, 0))
2387 2467
2388 self.SetSizer(sizer) 2468 self.SetSizer(sizer)
2389 sizer.Fit(self) 2469 sizer.Fit(self)
@@ -2434,7 +2514,7 @@ class PanelFFillThreshold(wx.Panel): @@ -2434,7 +2514,7 @@ class PanelFFillThreshold(wx.Panel):
2434 def OnSlideChanged(self, evt): 2514 def OnSlideChanged(self, evt):
2435 self.config.t0 = int(self.threshold.GetMinValue()) 2515 self.config.t0 = int(self.threshold.GetMinValue())
2436 self.config.t1 = int(self.threshold.GetMaxValue()) 2516 self.config.t1 = int(self.threshold.GetMaxValue())
2437 - print self.config.t0, self.config.t1 2517 + print(self.config.t0, self.config.t1)
2438 2518
2439 2519
2440 class PanelFFillDynamic(wx.Panel): 2520 class PanelFFillDynamic(wx.Panel):
@@ -2458,11 +2538,17 @@ class PanelFFillDynamic(wx.Panel): @@ -2458,11 +2538,17 @@ class PanelFFillDynamic(wx.Panel):
2458 2538
2459 sizer = wx.GridBagSizer(5, 5) 2539 sizer = wx.GridBagSizer(5, 5)
2460 2540
2461 - sizer.AddStretchSpacer((0, 0)) 2541 + try:
  2542 + sizer.Add(0, 0, (0, 0))
  2543 + except TypeError:
  2544 + sizer.AddStretchSpacer((0, 0))
2462 2545
2463 sizer.Add(self.use_ww_wl, (1, 0), (1, 6), flag=wx.LEFT, border=5) 2546 sizer.Add(self.use_ww_wl, (1, 0), (1, 6), flag=wx.LEFT, border=5)
2464 2547
2465 - sizer.AddStretchSpacer((2, 0)) 2548 + try:
  2549 + sizer.Add(0, 0, (2, 0))
  2550 + except TypeError:
  2551 + sizer.AddStretchSpacer((2, 0))
2466 2552
2467 sizer.Add(wx.StaticText(self, -1, _(u"Deviation")), (3, 0), (1, 6), flag=wx.LEFT, border=5) 2553 sizer.Add(wx.StaticText(self, -1, _(u"Deviation")), (3, 0), (1, 6), flag=wx.LEFT, border=5)
2468 2554
@@ -2472,7 +2558,10 @@ class PanelFFillDynamic(wx.Panel): @@ -2472,7 +2558,10 @@ class PanelFFillDynamic(wx.Panel):
2472 sizer.Add(wx.StaticText(self, -1, _(u"Max:")), (4, 2), flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT, border=9) 2558 sizer.Add(wx.StaticText(self, -1, _(u"Max:")), (4, 2), flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT, border=9)
2473 sizer.Add(self.deviation_max, (4, 3)) 2559 sizer.Add(self.deviation_max, (4, 3))
2474 2560
2475 - sizer.AddStretchSpacer((5, 0)) 2561 + try:
  2562 + sizer.Add(0, 0, (5, 0))
  2563 + except TypeError:
  2564 + sizer.AddStretchSpacer((5, 0))
2476 2565
2477 self.SetSizer(sizer) 2566 self.SetSizer(sizer)
2478 sizer.Fit(self) 2567 sizer.Fit(self)
@@ -2516,19 +2605,28 @@ class PanelFFillConfidence(wx.Panel): @@ -2516,19 +2605,28 @@ class PanelFFillConfidence(wx.Panel):
2516 2605
2517 sizer = wx.GridBagSizer(5, 5) 2606 sizer = wx.GridBagSizer(5, 5)
2518 2607
2519 - sizer.AddStretchSpacer((0, 0)) 2608 + try:
  2609 + sizer.Add(0, 0, (0, 0))
  2610 + except TypeError:
  2611 + sizer.AddStretchSpacer((0, 0))
2520 2612
2521 sizer.Add(self.use_ww_wl, (1, 0), (1, 6), flag=wx.LEFT, border=5) 2613 sizer.Add(self.use_ww_wl, (1, 0), (1, 6), flag=wx.LEFT, border=5)
2522 2614
2523 - sizer.AddStretchSpacer((2, 0)) 2615 + try:
  2616 + sizer.Add(0, 0, (2, 0))
  2617 + except TypeError:
  2618 + sizer.AddStretchSpacer((2, 0))
2524 2619
2525 sizer.Add(wx.StaticText(self, -1, _(u"Multiplier")), (3, 0), (1, 3), flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT, border=5) 2620 sizer.Add(wx.StaticText(self, -1, _(u"Multiplier")), (3, 0), (1, 3), flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT, border=5)
2526 - sizer.Add(self.spin_mult, (3, 3), (1, 2)) 2621 + sizer.Add(self.spin_mult, (3, 3), (1, 3))
2527 2622
2528 sizer.Add(wx.StaticText(self, -1, _(u"Iterations")), (4, 0), (1, 3), flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT, border=5) 2623 sizer.Add(wx.StaticText(self, -1, _(u"Iterations")), (4, 0), (1, 3), flag=wx.ALIGN_CENTER_VERTICAL|wx.LEFT, border=5)
2529 sizer.Add(self.spin_iters, (4, 3), (1, 2)) 2624 sizer.Add(self.spin_iters, (4, 3), (1, 2))
2530 2625
2531 - sizer.AddStretchSpacer((5, 0)) 2626 + try:
  2627 + sizer.Add(0, 0, (5, 0))
  2628 + except TypeError:
  2629 + sizer.AddStretchSpacer((5, 0))
2532 2630
2533 self.SetSizer(sizer) 2631 self.SetSizer(sizer)
2534 sizer.Fit(self) 2632 sizer.Fit(self)
@@ -2550,9 +2648,12 @@ class PanelFFillConfidence(wx.Panel): @@ -2550,9 +2648,12 @@ class PanelFFillConfidence(wx.Panel):
2550 2648
2551 class FFillOptionsDialog(wx.Dialog): 2649 class FFillOptionsDialog(wx.Dialog):
2552 def __init__(self, title, config): 2650 def __init__(self, title, config):
2553 - pre = wx.PreDialog()  
2554 - pre.Create(wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)  
2555 - self.PostCreate(pre) 2651 + try:
  2652 + pre = wx.PreDialog()
  2653 + pre.Create(wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
  2654 + self.PostCreate(pre)
  2655 + except AttributeError:
  2656 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
2556 2657
2557 self.config = config 2658 self.config = config
2558 2659
@@ -2651,7 +2752,7 @@ class FFillOptionsDialog(wx.Dialog): @@ -2651,7 +2752,7 @@ class FFillOptionsDialog(wx.Dialog):
2651 self.config.con_3d = 26 2752 self.config.con_3d = 26
2652 2753
2653 def OnClose(self, evt): 2754 def OnClose(self, evt):
2654 - print "ONCLOSE" 2755 + print("ONCLOSE")
2655 if self.config.dlg_visible: 2756 if self.config.dlg_visible:
2656 Publisher.sendMessage('Disable style', const.SLICE_STATE_MASK_FFILL) 2757 Publisher.sendMessage('Disable style', const.SLICE_STATE_MASK_FFILL)
2657 evt.Skip() 2758 evt.Skip()
@@ -2660,9 +2761,12 @@ class FFillOptionsDialog(wx.Dialog): @@ -2660,9 +2761,12 @@ class FFillOptionsDialog(wx.Dialog):
2660 2761
2661 class SelectPartsOptionsDialog(wx.Dialog): 2762 class SelectPartsOptionsDialog(wx.Dialog):
2662 def __init__(self, config): 2763 def __init__(self, config):
2663 - pre = wx.PreDialog()  
2664 - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Select mask parts"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)  
2665 - self.PostCreate(pre) 2764 + try:
  2765 + pre = wx.PreDialog()
  2766 + pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Select mask parts"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
  2767 + self.PostCreate(pre)
  2768 + except AttributeError:
  2769 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, _(u"Select mask parts"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
2666 2770
2667 self.config = config 2771 self.config = config
2668 2772
@@ -2700,7 +2804,7 @@ class SelectPartsOptionsDialog(wx.Dialog): @@ -2700,7 +2804,7 @@ class SelectPartsOptionsDialog(wx.Dialog):
2700 btn_sizer.Add(self.btn_ok, 0, flag=wx.ALIGN_RIGHT, border=5) 2804 btn_sizer.Add(self.btn_ok, 0, flag=wx.ALIGN_RIGHT, border=5)
2701 btn_sizer.Add(self.btn_cancel, 0, flag=wx.LEFT|wx.ALIGN_RIGHT, border=5) 2805 btn_sizer.Add(self.btn_cancel, 0, flag=wx.LEFT|wx.ALIGN_RIGHT, border=5)
2702 2806
2703 - sizer.AddSizer(btn_sizer, 0, flag=wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT, border=5) 2807 + sizer.Add(btn_sizer, 0, flag=wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT, border=5)
2704 sizer.AddSpacer(5) 2808 sizer.AddSpacer(5)
2705 2809
2706 self.SetSizer(sizer) 2810 self.SetSizer(sizer)
@@ -2741,10 +2845,13 @@ class SelectPartsOptionsDialog(wx.Dialog): @@ -2741,10 +2845,13 @@ class SelectPartsOptionsDialog(wx.Dialog):
2741 self.Destroy() 2845 self.Destroy()
2742 2846
2743 class FFillSegmentationOptionsDialog(wx.Dialog): 2847 class FFillSegmentationOptionsDialog(wx.Dialog):
2744 - def __init__(self, config):  
2745 - pre = wx.PreDialog()  
2746 - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Region growing"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)  
2747 - self.PostCreate(pre) 2848 + def __init__(self, config, ID=-1, title=_(u"Region growing"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT):
  2849 + try:
  2850 + pre = wx.PreDialog()
  2851 + pre.Create(wx.GetApp().GetTopWindow(), ID, title=title, style=style)
  2852 + self.PostCreate(pre)
  2853 + except AttributeError:
  2854 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style)
2748 2855
2749 self.config = config 2856 self.config = config
2750 2857
@@ -2816,20 +2923,38 @@ class FFillSegmentationOptionsDialog(wx.Dialog): @@ -2816,20 +2923,38 @@ class FFillSegmentationOptionsDialog(wx.Dialog):
2816 # Sizer 2923 # Sizer
2817 sizer = wx.GridBagSizer(2, 2) 2924 sizer = wx.GridBagSizer(2, 2)
2818 2925
2819 - sizer.AddStretchSpacer((0, 0)) 2926 + try:
  2927 + sizer.Add(0, 0, (0, 0))
  2928 + except TypeError:
  2929 + sizer.AddStretchSpacer((0, 0))
2820 sizer.Add(wx.StaticText(self, -1, _(u"Parameters")), (1, 0), (1, 6), flag=wx.LEFT, border=5) 2930 sizer.Add(wx.StaticText(self, -1, _(u"Parameters")), (1, 0), (1, 6), flag=wx.LEFT, border=5)
2821 - sizer.AddStretchSpacer((2, 0)) 2931 + try:
  2932 + sizer.Add(0, 0, (2, 0))
  2933 + except TypeError:
  2934 + sizer.AddStretchSpacer((2, 0))
2822 sizer.Add(self.panel_target, (3, 0), (1, 6), flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=7) 2935 sizer.Add(self.panel_target, (3, 0), (1, 6), flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=7)
2823 - sizer.AddStretchSpacer((4, 0)) 2936 + try:
  2937 + sizer.Add(0, 0, (4, 0))
  2938 + except TypeError:
  2939 + sizer.AddStretchSpacer((4, 0))
2824 sizer.Add(self.panel2dcon, (5, 0), (1, 6), flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=7) 2940 sizer.Add(self.panel2dcon, (5, 0), (1, 6), flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=7)
2825 - sizer.AddStretchSpacer((6, 0)) 2941 + try:
  2942 + sizer.Add(0, 0, (6, 0))
  2943 + except TypeError:
  2944 + sizer.AddStretchSpacer((6, 0))
2826 sizer.Add(self.panel3dcon, (7, 0), (1, 6), flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=7) 2945 sizer.Add(self.panel3dcon, (7, 0), (1, 6), flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=7)
2827 - sizer.AddStretchSpacer((8, 0)) 2946 + try:
  2947 + sizer.Add(0, 0, (8, 0))
  2948 + except TypeError:
  2949 + sizer.AddStretchSpacer((8, 0))
2828 2950
2829 sizer.Add(wx.StaticText(self, -1, _(u"Method")), (9, 0), (1, 1), flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL, border=7) 2951 sizer.Add(wx.StaticText(self, -1, _(u"Method")), (9, 0), (1, 1), flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL, border=7)
2830 sizer.Add(self.cmb_method, (9, 1), (1, 5), flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=7) 2952 sizer.Add(self.cmb_method, (9, 1), (1, 5), flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=7)
2831 2953
2832 - sizer.AddStretchSpacer((10, 0)) 2954 + try:
  2955 + sizer.Add(0, 0, (10, 0))
  2956 + except TypeError:
  2957 + sizer.AddStretchSpacer((10, 0))
2833 2958
2834 if self.config.method == 'dynamic': 2959 if self.config.method == 'dynamic':
2835 self.cmb_method.SetSelection(0) 2960 self.cmb_method.SetSelection(0)
@@ -2845,9 +2970,15 @@ class FFillSegmentationOptionsDialog(wx.Dialog): @@ -2845,9 +2970,15 @@ class FFillSegmentationOptionsDialog(wx.Dialog):
2845 sizer.Add(self.panel_ffill_threshold, (11, 0), (1, 6), flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=7) 2970 sizer.Add(self.panel_ffill_threshold, (11, 0), (1, 6), flag=wx.LEFT|wx.RIGHT|wx.EXPAND, border=7)
2846 self.config.method = 'threshold' 2971 self.config.method = 'threshold'
2847 2972
2848 - sizer.AddStretchSpacer((12, 0)) 2973 + try:
  2974 + sizer.Add(0, 0, (12, 0))
  2975 + except TypeError:
  2976 + sizer.AddStretchSpacer((12, 0))
2849 sizer.Add(self.close_btn, (13, 0), (1, 6), flag=wx.ALIGN_RIGHT|wx.RIGHT, border=5) 2977 sizer.Add(self.close_btn, (13, 0), (1, 6), flag=wx.ALIGN_RIGHT|wx.RIGHT, border=5)
2850 - sizer.AddStretchSpacer((14, 0)) 2978 + try:
  2979 + sizer.Add(0, 0, (14, 0))
  2980 + except TypeError:
  2981 + sizer.AddStretchSpacer((14, 0))
2851 2982
2852 self.SetSizer(sizer) 2983 self.SetSizer(sizer)
2853 sizer.Fit(self) 2984 sizer.Fit(self)
@@ -2919,13 +3050,16 @@ class FFillSegmentationOptionsDialog(wx.Dialog): @@ -2919,13 +3050,16 @@ class FFillSegmentationOptionsDialog(wx.Dialog):
2919 3050
2920 class CropOptionsDialog(wx.Dialog): 3051 class CropOptionsDialog(wx.Dialog):
2921 3052
2922 - def __init__(self, config): 3053 + def __init__(self, config, ID=-1, title=_(u"Crop mask"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT):
2923 self.config = config 3054 self.config = config
2924 - pre = wx.PreDialog() 3055 + try:
  3056 + pre = wx.PreDialog()
  3057 +
  3058 + pre.Create(wx.GetApp().GetTopWindow(), ID, title=title, style=style)
  3059 + self.PostCreate(pre)
  3060 + except AttributeError:
  3061 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), ID, title=title, style=style)
2925 3062
2926 - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Crop mask"),\  
2927 - style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)  
2928 - self.PostCreate(pre)  
2929 3063
2930 self._init_gui() 3064 self._init_gui()
2931 3065
@@ -3000,13 +3134,17 @@ class CropOptionsDialog(wx.Dialog): @@ -3000,13 +3134,17 @@ class CropOptionsDialog(wx.Dialog):
3000 gbs_button.Add(btn_cancel, (0,0)) 3134 gbs_button.Add(btn_cancel, (0,0))
3001 gbs_button.Add(btn_ok, (0,1)) 3135 gbs_button.Add(btn_ok, (0,1))
3002 3136
3003 - gbs_principal.AddSizer(gbs, (0,0), flag = wx.ALL|wx.EXPAND)  
3004 - gbs_principal.AddStretchSpacer((1,0))  
3005 - gbs_principal.AddStretchSpacer((2,0))  
3006 - gbs_principal.AddSizer(gbs_button, (3,0), flag = wx.ALIGN_RIGHT) 3137 + gbs_principal.Add(gbs, (0,0), flag = wx.ALL|wx.EXPAND)
  3138 + try:
  3139 + gbs_principal.Add(0, 0, (1, 0))
  3140 + gbs_principal.Add(0, 0, (2, 0))
  3141 + except TypeError:
  3142 + gbs_principal.AddStretchSpacer((1, 0))
  3143 + gbs_principal.AddStretchSpacer((2, 0))
  3144 + gbs_principal.Add(gbs_button, (3,0), flag = wx.ALIGN_RIGHT)
3007 3145
3008 box = wx.BoxSizer() 3146 box = wx.BoxSizer()
3009 - box.AddSizer(gbs_principal, 1, wx.ALL|wx.EXPAND, 10) 3147 + box.Add(gbs_principal, 1, wx.ALL|wx.EXPAND, 10)
3010 3148
3011 p.SetSizer(box) 3149 p.SetSizer(box)
3012 box.Fit(p) 3150 box.Fit(p)
@@ -3039,9 +3177,12 @@ class CropOptionsDialog(wx.Dialog): @@ -3039,9 +3177,12 @@ class CropOptionsDialog(wx.Dialog):
3039 3177
3040 class FillHolesAutoDialog(wx.Dialog): 3178 class FillHolesAutoDialog(wx.Dialog):
3041 def __init__(self, title): 3179 def __init__(self, title):
3042 - pre = wx.PreDialog()  
3043 - pre.Create(wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)  
3044 - self.PostCreate(pre) 3180 + try:
  3181 + pre = wx.PreDialog()
  3182 + pre.Create(wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
  3183 + self.PostCreate(pre)
  3184 + except AttributeError:
  3185 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
3045 3186
3046 self._init_gui() 3187 self._init_gui()
3047 3188
@@ -3056,10 +3197,13 @@ class FillHolesAutoDialog(wx.Dialog): @@ -3056,10 +3197,13 @@ class FillHolesAutoDialog(wx.Dialog):
3056 self.panel2dcon = Panel2DConnectivity(self, show_orientation=True, style=border_style|wx.TAB_TRAVERSAL) 3197 self.panel2dcon = Panel2DConnectivity(self, show_orientation=True, style=border_style|wx.TAB_TRAVERSAL)
3057 self.panel3dcon = Panel3DConnectivity(self, style=border_style|wx.TAB_TRAVERSAL) 3198 self.panel3dcon = Panel3DConnectivity(self, style=border_style|wx.TAB_TRAVERSAL)
3058 3199
3059 - self.panel_target.target_2d.SetValue(1)  
3060 self.panel2dcon.Enable(1) 3200 self.panel2dcon.Enable(1)
3061 self.panel3dcon.Enable(0) 3201 self.panel3dcon.Enable(0)
3062 3202
  3203 + self.panel_target.target_2d.SetValue(1)
  3204 + self.panel2dcon.conect2D_4.SetValue(1)
  3205 + self.panel3dcon.conect3D_6.SetValue(1)
  3206 +
3063 self.apply_btn = wx.Button(self, wx.ID_APPLY) 3207 self.apply_btn = wx.Button(self, wx.ID_APPLY)
3064 self.close_btn = wx.Button(self, wx.ID_CLOSE) 3208 self.close_btn = wx.Button(self, wx.ID_CLOSE)
3065 3209
@@ -3089,7 +3233,7 @@ class FillHolesAutoDialog(wx.Dialog): @@ -3089,7 +3233,7 @@ class FillHolesAutoDialog(wx.Dialog):
3089 btn_sizer.Add(self.apply_btn, 0, flag=wx.ALIGN_RIGHT, border=5) 3233 btn_sizer.Add(self.apply_btn, 0, flag=wx.ALIGN_RIGHT, border=5)
3090 btn_sizer.Add(self.close_btn, 0, flag=wx.LEFT|wx.ALIGN_RIGHT, border=5) 3234 btn_sizer.Add(self.close_btn, 0, flag=wx.LEFT|wx.ALIGN_RIGHT, border=5)
3091 3235
3092 - sizer.AddSizer(btn_sizer, 0, flag=wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT, border=5) 3236 + sizer.Add(btn_sizer, 0, flag=wx.ALIGN_RIGHT|wx.LEFT|wx.RIGHT, border=5)
3093 3237
3094 sizer.AddSpacer(5) 3238 sizer.AddSpacer(5)
3095 3239
@@ -3147,10 +3291,14 @@ class ObjectCalibrationDialog(wx.Dialog): @@ -3147,10 +3291,14 @@ class ObjectCalibrationDialog(wx.Dialog):
3147 self.obj_fiducials = np.full([5, 3], np.nan) 3291 self.obj_fiducials = np.full([5, 3], np.nan)
3148 self.obj_orients = np.full([5, 3], np.nan) 3292 self.obj_orients = np.full([5, 3], np.nan)
3149 3293
3150 - pre = wx.PreDialog()  
3151 - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Object calibration"), size=(450, 440),  
3152 - style=wx.DEFAULT_DIALOG_STYLE | wx.FRAME_FLOAT_ON_PARENT)  
3153 - self.PostCreate(pre) 3294 + try:
  3295 + pre = wx.PreDialog()
  3296 + pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Object calibration"), size=(450, 440),
  3297 + style=wx.DEFAULT_DIALOG_STYLE | wx.FRAME_FLOAT_ON_PARENT)
  3298 + self.PostCreate(pre)
  3299 + except AttributeError:
  3300 + wx.Dialog.__init__(self, wx.GetApp().GetTopWindow(), -1, _(u"Object calibration"), size=(450, 440),
  3301 + style=wx.DEFAULT_DIALOG_STYLE | wx.FRAME_FLOAT_ON_PARENT)
3154 3302
3155 self._init_gui() 3303 self._init_gui()
3156 self.LoadObject() 3304 self.LoadObject()
@@ -3191,8 +3339,8 @@ class ObjectCalibrationDialog(wx.Dialog): @@ -3191,8 +3339,8 @@ class ObjectCalibrationDialog(wx.Dialog):
3191 tips_obj = const.TIPS_OBJ 3339 tips_obj = const.TIPS_OBJ
3192 3340
3193 for k in btns_obj: 3341 for k in btns_obj:
3194 - n = btns_obj[k].keys()[0]  
3195 - lab = btns_obj[k].values()[0] 3342 + n = list(btns_obj[k].keys())[0]
  3343 + lab = list(btns_obj[k].values())[0]
3196 self.btns_coord[n] = wx.Button(self, k, label=lab, size=wx.Size(60, 23)) 3344 self.btns_coord[n] = wx.Button(self, k, label=lab, size=wx.Size(60, 23))
3197 self.btns_coord[n].SetToolTip(wx.ToolTip(tips_obj[n])) 3345 self.btns_coord[n].SetToolTip(wx.ToolTip(tips_obj[n]))
3198 self.btns_coord[n].Bind(wx.EVT_BUTTON, self.OnGetObjectFiducials) 3346 self.btns_coord[n].Bind(wx.EVT_BUTTON, self.OnGetObjectFiducials)
@@ -3332,7 +3480,7 @@ class ObjectCalibrationDialog(wx.Dialog): @@ -3332,7 +3480,7 @@ class ObjectCalibrationDialog(wx.Dialog):
3332 return ball_actor, tactor 3480 return ball_actor, tactor
3333 3481
3334 def OnGetObjectFiducials(self, evt): 3482 def OnGetObjectFiducials(self, evt):
3335 - btn_id = const.BTNS_OBJ[evt.GetId()].keys()[0] 3483 + btn_id = list(const.BTNS_OBJ[evt.GetId()].keys())[0]
3336 3484
3337 if self.trk_init and self.tracker_id: 3485 if self.trk_init and self.tracker_id:
3338 coord_raw = dco.GetCoordinates(self.trk_init, self.tracker_id, self.obj_ref_id) 3486 coord_raw = dco.GetCoordinates(self.trk_init, self.tracker_id, self.obj_ref_id)
invesalius/gui/dicom_preview_panel.py
@@ -272,7 +272,10 @@ class Preview(wx.Panel): @@ -272,7 +272,10 @@ class Preview(wx.Panel):
272 def OnEnter(self, evt): 272 def OnEnter(self, evt):
273 if not self.select_on: 273 if not self.select_on:
274 #c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DHILIGHT) 274 #c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_3DHILIGHT)
275 - c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE) 275 + try:
  276 + c = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)
  277 + except AttributeError:
  278 + c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE)
276 self.SetBackgroundColour(c) 279 self.SetBackgroundColour(c)
277 280
278 def OnLeave(self, evt): 281 def OnLeave(self, evt):
@@ -320,7 +323,10 @@ class Preview(wx.Panel): @@ -320,7 +323,10 @@ class Preview(wx.Panel):
320 323
321 def Select(self, on=True): 324 def Select(self, on=True):
322 if self.select_on: 325 if self.select_on:
323 - c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT) 326 + try:
  327 + c = wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT)
  328 + except AttributeError:
  329 + c = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT)
324 else: 330 else:
325 c = (PREVIEW_BACKGROUND) 331 c = (PREVIEW_BACKGROUND)
326 self.SetBackgroundColour(c) 332 self.SetBackgroundColour(c)
@@ -355,10 +361,10 @@ class DicomPreviewSeries(wx.Panel): @@ -355,10 +361,10 @@ class DicomPreviewSeries(wx.Panel):
355 self.grid = wx.GridSizer(rows=NROWS, cols=NCOLS, vgap=3, hgap=3) 361 self.grid = wx.GridSizer(rows=NROWS, cols=NCOLS, vgap=3, hgap=3)
356 362
357 sizer = wx.BoxSizer(wx.HORIZONTAL) 363 sizer = wx.BoxSizer(wx.HORIZONTAL)
358 - sizer.AddSizer(self.grid, 1, wx.EXPAND|wx.GROW|wx.ALL, 2) 364 + sizer.Add(self.grid, 1, wx.EXPAND|wx.GROW|wx.ALL, 2)
359 365
360 background_sizer = wx.BoxSizer(wx.HORIZONTAL) 366 background_sizer = wx.BoxSizer(wx.HORIZONTAL)
361 - background_sizer.AddSizer(sizer, 1, wx.EXPAND|wx.GROW|wx.ALL, 2) 367 + background_sizer.Add(sizer, 1, wx.EXPAND|wx.GROW|wx.ALL, 2)
362 background_sizer.Add(scroll, 0, wx.EXPAND|wx.GROW) 368 background_sizer.Add(scroll, 0, wx.EXPAND|wx.GROW)
363 self.SetSizer(background_sizer) 369 self.SetSizer(background_sizer)
364 background_sizer.Fit(self) 370 background_sizer.Fit(self)
@@ -374,8 +380,8 @@ class DicomPreviewSeries(wx.Panel): @@ -374,8 +380,8 @@ class DicomPreviewSeries(wx.Panel):
374 380
375 def _Add_Panels_Preview(self): 381 def _Add_Panels_Preview(self):
376 self.previews = [] 382 self.previews = []
377 - for i in xrange(NROWS):  
378 - for j in xrange(NCOLS): 383 + for i in range(NROWS):
  384 + for j in range(NCOLS):
379 p = Preview(self) 385 p = Preview(self)
380 p.Bind(EVT_PREVIEW_CLICK, self.OnSelect) 386 p.Bind(EVT_PREVIEW_CLICK, self.OnSelect)
381 #if (i == j == 0): 387 #if (i == j == 0):
@@ -432,7 +438,7 @@ class DicomPreviewSeries(wx.Panel): @@ -432,7 +438,7 @@ class DicomPreviewSeries(wx.Panel):
432 initial = self.displayed_position * NCOLS 438 initial = self.displayed_position * NCOLS
433 final = initial + NUM_PREVIEWS 439 final = initial + NUM_PREVIEWS
434 if len(self.files) < final: 440 if len(self.files) < final:
435 - for i in xrange(final-len(self.files)): 441 + for i in range(final-len(self.files)):
436 try: 442 try:
437 self.previews[-i-1].Hide() 443 self.previews[-i-1].Hide()
438 except IndexError: 444 except IndexError:
@@ -441,7 +447,7 @@ class DicomPreviewSeries(wx.Panel): @@ -441,7 +447,7 @@ class DicomPreviewSeries(wx.Panel):
441 self.nhidden_last_display = final-len(self.files) 447 self.nhidden_last_display = final-len(self.files)
442 else: 448 else:
443 if self.nhidden_last_display: 449 if self.nhidden_last_display:
444 - for i in xrange(self.nhidden_last_display): 450 + for i in range(self.nhidden_last_display):
445 try: 451 try:
446 self.previews[-i-1].Show() 452 self.previews[-i-1].Show()
447 except IndexError: 453 except IndexError:
@@ -492,10 +498,10 @@ class DicomPreviewSlice(wx.Panel): @@ -492,10 +498,10 @@ class DicomPreviewSlice(wx.Panel):
492 self.grid = wx.GridSizer(rows=NROWS, cols=NCOLS, vgap=3, hgap=3) 498 self.grid = wx.GridSizer(rows=NROWS, cols=NCOLS, vgap=3, hgap=3)
493 499
494 sizer = wx.BoxSizer(wx.HORIZONTAL) 500 sizer = wx.BoxSizer(wx.HORIZONTAL)
495 - sizer.AddSizer(self.grid, 1, wx.EXPAND|wx.GROW|wx.ALL, 2) 501 + sizer.Add(self.grid, 1, wx.EXPAND|wx.GROW|wx.ALL, 2)
496 502
497 background_sizer = wx.BoxSizer(wx.HORIZONTAL) 503 background_sizer = wx.BoxSizer(wx.HORIZONTAL)
498 - background_sizer.AddSizer(sizer, 1, wx.EXPAND|wx.GROW|wx.ALL, 2) 504 + background_sizer.Add(sizer, 1, wx.EXPAND|wx.GROW|wx.ALL, 2)
499 background_sizer.Add(scroll, 0, wx.EXPAND|wx.GROW) 505 background_sizer.Add(scroll, 0, wx.EXPAND|wx.GROW)
500 self.SetSizer(background_sizer) 506 self.SetSizer(background_sizer)
501 background_sizer.Fit(self) 507 background_sizer.Fit(self)
@@ -511,8 +517,8 @@ class DicomPreviewSlice(wx.Panel): @@ -511,8 +517,8 @@ class DicomPreviewSlice(wx.Panel):
511 517
512 def _Add_Panels_Preview(self): 518 def _Add_Panels_Preview(self):
513 self.previews = [] 519 self.previews = []
514 - for i in xrange(NROWS):  
515 - for j in xrange(NCOLS): 520 + for i in range(NROWS):
  521 + for j in range(NCOLS):
516 p = Preview(self) 522 p = Preview(self)
517 p.Bind(EVT_PREVIEW_CLICK, self.OnPreviewClick) 523 p.Bind(EVT_PREVIEW_CLICK, self.OnPreviewClick)
518 #p.Hide() 524 #p.Hide()
@@ -545,7 +551,7 @@ class DicomPreviewSlice(wx.Panel): @@ -545,7 +551,7 @@ class DicomPreviewSlice(wx.Panel):
545 if isinstance(dicom.image.thumbnail_path, list): 551 if isinstance(dicom.image.thumbnail_path, list):
546 _slice = 0 552 _slice = 0
547 for thumbnail in dicom.image.thumbnail_path: 553 for thumbnail in dicom.image.thumbnail_path:
548 - print thumbnail 554 + print(thumbnail)
549 info = DicomInfo(n, dicom, 555 info = DicomInfo(n, dicom,
550 _("Image %d") % (n), 556 _("Image %d") % (n),
551 "%.2f" % (dicom.image.position[2]), _slice) 557 "%.2f" % (dicom.image.position[2]), _slice)
@@ -577,7 +583,7 @@ class DicomPreviewSlice(wx.Panel): @@ -577,7 +583,7 @@ class DicomPreviewSlice(wx.Panel):
577 if isinstance(dicom.image.thumbnail_path, list): 583 if isinstance(dicom.image.thumbnail_path, list):
578 _slice = 0 584 _slice = 0
579 for thumbnail in dicom.image.thumbnail_path: 585 for thumbnail in dicom.image.thumbnail_path:
580 - print thumbnail 586 + print(thumbnail)
581 info = DicomInfo(n, dicom, 587 info = DicomInfo(n, dicom,
582 _("Image %d") % int(n), 588 _("Image %d") % int(n),
583 "%.2f" % (dicom.image.position[2]), _slice) 589 "%.2f" % (dicom.image.position[2]), _slice)
@@ -603,7 +609,7 @@ class DicomPreviewSlice(wx.Panel): @@ -603,7 +609,7 @@ class DicomPreviewSlice(wx.Panel):
603 initial = self.displayed_position * NCOLS 609 initial = self.displayed_position * NCOLS
604 final = initial + NUM_PREVIEWS 610 final = initial + NUM_PREVIEWS
605 if len(self.files) < final: 611 if len(self.files) < final:
606 - for i in xrange(final-len(self.files)): 612 + for i in range(final-len(self.files)):
607 try: 613 try:
608 self.previews[-i-1].Hide() 614 self.previews[-i-1].Hide()
609 except IndexError: 615 except IndexError:
@@ -611,7 +617,7 @@ class DicomPreviewSlice(wx.Panel): @@ -611,7 +617,7 @@ class DicomPreviewSlice(wx.Panel):
611 self.nhidden_last_display = final-len(self.files) 617 self.nhidden_last_display = final-len(self.files)
612 else: 618 else:
613 if self.nhidden_last_display: 619 if self.nhidden_last_display:
614 - for i in xrange(self.nhidden_last_display): 620 + for i in range(self.nhidden_last_display):
615 try: 621 try:
616 self.previews[-i-1].Show() 622 self.previews[-i-1].Show()
617 except IndexError: 623 except IndexError:
@@ -648,7 +654,7 @@ class DicomPreviewSlice(wx.Panel): @@ -648,7 +654,7 @@ class DicomPreviewSlice(wx.Panel):
648 self.first_selection = dicom_id 654 self.first_selection = dicom_id
649 self.last_selection = dicom_id 655 self.last_selection = dicom_id
650 656
651 - for i in xrange(len(self.files)): 657 + for i in range(len(self.files)):
652 658
653 if i == dicom_id: 659 if i == dicom_id:
654 self.files[i].selected = True 660 self.files[i].selected = True
@@ -666,7 +672,7 @@ class DicomPreviewSlice(wx.Panel): @@ -666,7 +672,7 @@ class DicomPreviewSlice(wx.Panel):
666 self.selected_panel.select_on = self.selected_panel is evt.GetEventObject() 672 self.selected_panel.select_on = self.selected_panel is evt.GetEventObject()
667 673
668 if self.first_selection != self.last_selection: 674 if self.first_selection != self.last_selection:
669 - for i in xrange(len(self.files)): 675 + for i in range(len(self.files)):
670 if i >= self.first_selection and i <= self.last_selection: 676 if i >= self.first_selection and i <= self.last_selection:
671 self.files[i].selected = True 677 self.files[i].selected = True
672 else: 678 else:
@@ -772,7 +778,7 @@ class SingleImagePreview(wx.Panel): @@ -772,7 +778,7 @@ class SingleImagePreview(wx.Panel):
772 maxValue=99, 778 maxValue=99,
773 style=wx.SL_HORIZONTAL|wx.SL_AUTOTICKS) 779 style=wx.SL_HORIZONTAL|wx.SL_AUTOTICKS)
774 slider.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) 780 slider.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
775 - slider.SetTickFreq(1, 1) 781 + slider.SetTickFreq(1)
776 self.slider = slider 782 self.slider = slider
777 783
778 checkbox = wx.CheckBox(self, -1, _("Auto-play")) 784 checkbox = wx.CheckBox(self, -1, _("Auto-play"))
invesalius/gui/frame.py
@@ -24,6 +24,12 @@ import sys @@ -24,6 +24,12 @@ import sys
24 import webbrowser 24 import webbrowser
25 25
26 import wx 26 import wx
  27 +
  28 +try:
  29 + from wx.adv import TaskBarIcon as wx_TaskBarIcon
  30 +except ImportError:
  31 + from wx import TaskBarIcon as wx_TaskBarIcon
  32 +
27 import wx.aui 33 import wx.aui
28 from wx.lib.pubsub import pub as Publisher 34 from wx.lib.pubsub import pub as Publisher
29 import wx.lib.agw.toasterbox as TB 35 import wx.lib.agw.toasterbox as TB
@@ -386,6 +392,7 @@ class Frame(wx.Frame): @@ -386,6 +392,7 @@ class Frame(wx.Frame):
386 s = ses.Session() 392 s = ses.Session()
387 if not s.IsOpen() or not s.project_path: 393 if not s.IsOpen() or not s.project_path:
388 Publisher.sendMessage('Exit') 394 Publisher.sendMessage('Exit')
  395 + self.aui_manager.UnInit()
389 396
390 def OnMenuClick(self, evt): 397 def OnMenuClick(self, evt):
391 """ 398 """
@@ -1127,7 +1134,7 @@ class StatusBar(wx.StatusBar): @@ -1127,7 +1134,7 @@ class StatusBar(wx.StatusBar):
1127 # ------------------------------------------------------------------ 1134 # ------------------------------------------------------------------
1128 # ------------------------------------------------------------------ 1135 # ------------------------------------------------------------------
1129 1136
1130 -class TaskBarIcon(wx.TaskBarIcon): 1137 +class TaskBarIcon(wx_TaskBarIcon):
1131 """ 1138 """
1132 TaskBarIcon has different behaviours according to the platform: 1139 TaskBarIcon has different behaviours according to the platform:
1133 - win32: Show icon on "Notification Area" (near clock) 1140 - win32: Show icon on "Notification Area" (near clock)
@@ -1135,7 +1142,7 @@ class TaskBarIcon(wx.TaskBarIcon): @@ -1135,7 +1142,7 @@ class TaskBarIcon(wx.TaskBarIcon):
1135 - linux2: Show icon on "Notification Area" (near clock) 1142 - linux2: Show icon on "Notification Area" (near clock)
1136 """ 1143 """
1137 def __init__(self, parent=None): 1144 def __init__(self, parent=None):
1138 - wx.TaskBarIcon.__init__(self) 1145 + wx_TaskBarIcon.__init__(self)
1139 self.frame = parent 1146 self.frame = parent
1140 1147
1141 icon = wx.Icon(os.path.join(const.ICON_DIR, "invesalius.ico"), 1148 icon = wx.Icon(os.path.join(const.ICON_DIR, "invesalius.ico"),
invesalius/gui/import_bitmap_panel.py
@@ -101,7 +101,7 @@ class InnerPanel(wx.Panel): @@ -101,7 +101,7 @@ class InnerPanel(wx.Panel):
101 self.combo_interval.SetSelection(0) 101 self.combo_interval.SetSelection(0)
102 102
103 inner_sizer = wx.BoxSizer(wx.HORIZONTAL) 103 inner_sizer = wx.BoxSizer(wx.HORIZONTAL)
104 - inner_sizer.AddSizer(btnsizer, 0, wx.LEFT|wx.TOP, 5) 104 + inner_sizer.Add(btnsizer, 0, wx.LEFT|wx.TOP, 5)
105 inner_sizer.Add(self.combo_interval, 0, wx.LEFT|wx.RIGHT|wx.TOP, 5) 105 inner_sizer.Add(self.combo_interval, 0, wx.LEFT|wx.RIGHT|wx.TOP, 5)
106 panel.SetSizer(inner_sizer) 106 panel.SetSizer(inner_sizer)
107 inner_sizer.Fit(panel) 107 inner_sizer.Fit(panel)
@@ -192,7 +192,7 @@ class TextPanel(wx.Panel): @@ -192,7 +192,7 @@ class TextPanel(wx.Panel):
192 wx.TR_DEFAULT_STYLE 192 wx.TR_DEFAULT_STYLE
193 | wx.TR_HIDE_ROOT 193 | wx.TR_HIDE_ROOT
194 | wx.TR_ROW_LINES 194 | wx.TR_ROW_LINES
195 - | wx.TR_COLUMN_LINES 195 + # | wx.TR_COLUMN_LINES
196 | wx.TR_FULL_ROW_HIGHLIGHT 196 | wx.TR_FULL_ROW_HIGHLIGHT
197 | wx.TR_MULTIPLE 197 | wx.TR_MULTIPLE
198 | wx.TR_HIDE_ROOT 198 | wx.TR_HIDE_ROOT
@@ -308,7 +308,8 @@ class ImagePanel(wx.Panel): @@ -308,7 +308,8 @@ class ImagePanel(wx.Panel):
308 splitter.SetOrientation(wx.HORIZONTAL) 308 splitter.SetOrientation(wx.HORIZONTAL)
309 self.splitter = splitter 309 self.splitter = splitter
310 310
311 - splitter.ContainingSizer = wx.BoxSizer(wx.HORIZONTAL) 311 + # TODO: Rever isso
  312 + # splitter.ContainingSizer = wx.BoxSizer(wx.HORIZONTAL)
312 313
313 sizer = wx.BoxSizer(wx.HORIZONTAL) 314 sizer = wx.BoxSizer(wx.HORIZONTAL)
314 sizer.Add(splitter, 1, wx.EXPAND) 315 sizer.Add(splitter, 1, wx.EXPAND)
invesalius/gui/import_network_panel.py
@@ -110,7 +110,7 @@ class InnerPanel(wx.Panel): @@ -110,7 +110,7 @@ class InnerPanel(wx.Panel):
110 self.combo_interval.SetSelection(0) 110 self.combo_interval.SetSelection(0)
111 111
112 inner_sizer = wx.BoxSizer(wx.HORIZONTAL) 112 inner_sizer = wx.BoxSizer(wx.HORIZONTAL)
113 - inner_sizer.AddSizer(btnsizer, 0, wx.LEFT|wx.TOP, 5) 113 + inner_sizer.Add(btnsizer, 0, wx.LEFT|wx.TOP, 5)
114 inner_sizer.Add(self.combo_interval, 0, wx.LEFT|wx.RIGHT|wx.TOP, 5) 114 inner_sizer.Add(self.combo_interval, 0, wx.LEFT|wx.RIGHT|wx.TOP, 5)
115 panel.SetSizer(inner_sizer) 115 panel.SetSizer(inner_sizer)
116 inner_sizer.Fit(panel) 116 inner_sizer.Fit(panel)
@@ -230,7 +230,7 @@ class TextPanel(wx.Panel): @@ -230,7 +230,7 @@ class TextPanel(wx.Panel):
230 wx.TR_DEFAULT_STYLE 230 wx.TR_DEFAULT_STYLE
231 | wx.TR_HIDE_ROOT 231 | wx.TR_HIDE_ROOT
232 | wx.TR_ROW_LINES 232 | wx.TR_ROW_LINES
233 - | wx.TR_COLUMN_LINES 233 + # | wx.TR_COLUMN_LINES
234 | wx.TR_FULL_ROW_HIGHLIGHT 234 | wx.TR_FULL_ROW_HIGHLIGHT
235 | wx.TR_SINGLE 235 | wx.TR_SINGLE
236 ) 236 )
@@ -507,8 +507,8 @@ class FindPanel(wx.Panel): @@ -507,8 +507,8 @@ class FindPanel(wx.Panel):
507 sizer_txt_find.Add(self.btn_find) 507 sizer_txt_find.Add(self.btn_find)
508 508
509 self.sizer.Add((0, 5), 0, wx.EXPAND|wx.HORIZONTAL) 509 self.sizer.Add((0, 5), 0, wx.EXPAND|wx.HORIZONTAL)
510 - self.sizer.AddSizer(sizer_word_label)  
511 - self.sizer.AddSizer(sizer_txt_find) 510 + self.sizer.Add(sizer_word_label)
  511 + self.sizer.Add(sizer_txt_find)
512 512
513 #self.sizer.Add(self.serie_preview, 1, wx.EXPAND | wx.ALL, 5) 513 #self.sizer.Add(self.serie_preview, 1, wx.EXPAND | wx.ALL, 5)
514 #self.sizer.Add(self.dicom_preview, 1, wx.EXPAND | wx.ALL, 5) 514 #self.sizer.Add(self.dicom_preview, 1, wx.EXPAND | wx.ALL, 5)
@@ -568,7 +568,8 @@ class HostFindPanel(wx.Panel): @@ -568,7 +568,8 @@ class HostFindPanel(wx.Panel):
568 splitter.SetOrientation(wx.HORIZONTAL) 568 splitter.SetOrientation(wx.HORIZONTAL)
569 self.splitter = splitter 569 self.splitter = splitter
570 570
571 - splitter.ContainingSizer = wx.BoxSizer(wx.HORIZONTAL) 571 + # TODO: Rever isso
  572 + # splitter.ContainingSizer = wx.BoxSizer(wx.HORIZONTAL)
572 573
573 sizer = wx.BoxSizer(wx.HORIZONTAL) 574 sizer = wx.BoxSizer(wx.HORIZONTAL)
574 sizer.Add(splitter, 1, wx.EXPAND) 575 sizer.Add(splitter, 1, wx.EXPAND)
@@ -673,7 +674,7 @@ class NodesPanel(wx.Panel): @@ -673,7 +674,7 @@ class NodesPanel(wx.Panel):
673 self.tree_node.SetColumnWidth(4, 80) 674 self.tree_node.SetColumnWidth(4, 80)
674 675
675 self.hosts[0] = [True, "localhost", "", "invesalius"] 676 self.hosts[0] = [True, "localhost", "", "invesalius"]
676 - index = self.tree_node.InsertStringItem(sys.maxint, "") 677 + index = self.tree_node.InsertStringItem(sys.maxsize, "")
677 self.tree_node.SetStringItem(index, 1, "localhost") 678 self.tree_node.SetStringItem(index, 1, "localhost")
678 self.tree_node.SetStringItem(index, 2, "") 679 self.tree_node.SetStringItem(index, 2, "")
679 self.tree_node.SetStringItem(index, 3, "invesalius") 680 self.tree_node.SetStringItem(index, 3, "invesalius")
@@ -704,7 +705,7 @@ class NodesPanel(wx.Panel): @@ -704,7 +705,7 @@ class NodesPanel(wx.Panel):
704 705
705 sizer = wx.BoxSizer(wx.VERTICAL) 706 sizer = wx.BoxSizer(wx.VERTICAL)
706 sizer.Add(self.tree_node, 85, wx.GROW|wx.EXPAND) 707 sizer.Add(self.tree_node, 85, wx.GROW|wx.EXPAND)
707 - sizer.AddSizer(sizer_btn, 15) 708 + sizer.Add(sizer_btn, 15)
708 sizer.Fit(self) 709 sizer.Fit(self)
709 self.SetSizer(sizer) 710 self.SetSizer(sizer)
710 self.Layout() 711 self.Layout()
@@ -728,7 +729,7 @@ class NodesPanel(wx.Panel): @@ -728,7 +729,7 @@ class NodesPanel(wx.Panel):
728 729
729 def OnButtonAdd(self, evt): 730 def OnButtonAdd(self, evt):
730 #adiciona vazio a coluna de check 731 #adiciona vazio a coluna de check
731 - index = self.tree_node.InsertStringItem(sys.maxint, "") 732 + index = self.tree_node.InsertStringItem(sys.maxsize, "")
732 733
733 self.hosts[index] = [True, "localhost", "80", ""] 734 self.hosts[index] = [True, "localhost", "80", ""]
734 self.tree_node.SetStringItem(index, 1, "localhost") 735 self.tree_node.SetStringItem(index, 1, "localhost")
invesalius/gui/import_panel.py
@@ -103,7 +103,7 @@ class InnerPanel(wx.Panel): @@ -103,7 +103,7 @@ class InnerPanel(wx.Panel):
103 self.combo_interval.SetSelection(0) 103 self.combo_interval.SetSelection(0)
104 104
105 inner_sizer = wx.BoxSizer(wx.HORIZONTAL) 105 inner_sizer = wx.BoxSizer(wx.HORIZONTAL)
106 - inner_sizer.AddSizer(btnsizer, 0, wx.LEFT|wx.TOP, 5) 106 + inner_sizer.Add(btnsizer, 0, wx.LEFT|wx.TOP, 5)
107 inner_sizer.Add(self.combo_interval, 0, wx.LEFT|wx.RIGHT|wx.TOP, 5) 107 inner_sizer.Add(self.combo_interval, 0, wx.LEFT|wx.RIGHT|wx.TOP, 5)
108 panel.SetSizer(inner_sizer) 108 panel.SetSizer(inner_sizer)
109 inner_sizer.Fit(panel) 109 inner_sizer.Fit(panel)
@@ -215,7 +215,7 @@ class TextPanel(wx.Panel): @@ -215,7 +215,7 @@ class TextPanel(wx.Panel):
215 wx.TR_DEFAULT_STYLE 215 wx.TR_DEFAULT_STYLE
216 | wx.TR_HIDE_ROOT 216 | wx.TR_HIDE_ROOT
217 | wx.TR_ROW_LINES 217 | wx.TR_ROW_LINES
218 - | wx.TR_COLUMN_LINES 218 + # | wx.TR_COLUMN_LINES
219 | wx.TR_FULL_ROW_HIGHLIGHT 219 | wx.TR_FULL_ROW_HIGHLIGHT
220 | wx.TR_SINGLE 220 | wx.TR_SINGLE
221 ) 221 )
@@ -362,7 +362,8 @@ class ImagePanel(wx.Panel): @@ -362,7 +362,8 @@ class ImagePanel(wx.Panel):
362 splitter.SetOrientation(wx.HORIZONTAL) 362 splitter.SetOrientation(wx.HORIZONTAL)
363 self.splitter = splitter 363 self.splitter = splitter
364 364
365 - splitter.ContainingSizer = wx.BoxSizer(wx.HORIZONTAL) 365 + # TODO Rever isso
  366 + # splitter.ContainingSizer = wx.BoxSizer(wx.HORIZONTAL)
366 367
367 sizer = wx.BoxSizer(wx.HORIZONTAL) 368 sizer = wx.BoxSizer(wx.HORIZONTAL)
368 sizer.Add(splitter, 1, wx.EXPAND) 369 sizer.Add(splitter, 1, wx.EXPAND)
invesalius/gui/language_dialog.py
@@ -20,7 +20,10 @@ @@ -20,7 +20,10 @@
20 import os 20 import os
21 import sys 21 import sys
22 import wx 22 import wx
23 -import wx.combo 23 +try:
  24 + from wx.adv import BitmapComboBox
  25 +except ImportError:
  26 + from wx.combo import BitmapComboBox
24 27
25 import invesalius.i18n as i18n 28 import invesalius.i18n as i18n
26 29
@@ -48,7 +51,7 @@ class ComboBoxLanguage: @@ -48,7 +51,7 @@ class ComboBoxLanguage:
48 51
49 # Retrieve locales names and sort them 52 # Retrieve locales names and sort them
50 self.locales = dict_locales.values() 53 self.locales = dict_locales.values()
51 - self.locales.sort() 54 + self.locales = sorted(self.locales)
52 55
53 # Retrieve locales keys (eg: pt_BR for Portuguese(Brazilian)) 56 # Retrieve locales keys (eg: pt_BR for Portuguese(Brazilian))
54 self.locales_key = [dict_locales.get_key(value)[0] for value in self.locales] 57 self.locales_key = [dict_locales.get_key(value)[0] for value in self.locales]
@@ -65,7 +68,7 @@ class ComboBoxLanguage: @@ -65,7 +68,7 @@ class ComboBoxLanguage:
65 selection = self.locales_key.index('en') 68 selection = self.locales_key.index('en')
66 69
67 # Create bitmap combo 70 # Create bitmap combo
68 - self.bitmapCmb = bitmapCmb = wx.combo.BitmapComboBox(parent, style=wx.CB_READONLY) 71 + self.bitmapCmb = bitmapCmb = BitmapComboBox(parent, style=wx.CB_READONLY)
69 for key in self.locales_key: 72 for key in self.locales_key:
70 # Based on composed flag filename, get bitmap 73 # Based on composed flag filename, get bitmap
71 filepath = os.path.join(ICON_DIR, "%s.bmp"%(key)) 74 filepath = os.path.join(ICON_DIR, "%s.bmp"%(key))
@@ -117,7 +120,7 @@ class LanguageDialog(wx.Dialog): @@ -117,7 +120,7 @@ class LanguageDialog(wx.Dialog):
117 # selection = self.locales_key.index('en') 120 # selection = self.locales_key.index('en')
118 121
119 # # Create bitmap combo 122 # # Create bitmap combo
120 - # self.bitmapCmb = bitmapCmb = wx.combo.BitmapComboBox(self, style=wx.CB_READONLY) 123 + # self.bitmapCmb = bitmapCmb = BitmapComboBox(self, style=wx.CB_READONLY)
121 # for key in self.locales_key: 124 # for key in self.locales_key:
122 # # Based on composed flag filename, get bitmap 125 # # Based on composed flag filename, get bitmap
123 # filepath = os.path.join(ICON_DIR, "%s.bmp"%(key)) 126 # filepath = os.path.join(ICON_DIR, "%s.bmp"%(key))
invesalius/gui/preferences.py
@@ -17,11 +17,15 @@ class Preferences(wx.Dialog): @@ -17,11 +17,15 @@ 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): 18 pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE):
19 19
20 - pre = wx.PreDialog()  
21 - pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)  
22 - pre.Create(parent, ID, title, pos, size, style) 20 + try:
  21 + pre = wx.PreDialog()
  22 + pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
  23 + pre.Create(parent, ID, title, pos, size, style)
23 24
24 - self.PostCreate(pre) 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)
25 29
26 sizer = wx.BoxSizer(wx.VERTICAL) 30 sizer = wx.BoxSizer(wx.VERTICAL)
27 31
@@ -55,7 +59,7 @@ class Preferences(wx.Dialog): @@ -55,7 +59,7 @@ class Preferences(wx.Dialog):
55 59
56 btnsizer.Realize() 60 btnsizer.Realize()
57 61
58 - sizer.AddSizer(btnsizer, 10, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP|wx.BOTTOM, 5) 62 + sizer.Add(btnsizer, 10, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP|wx.BOTTOM, 5)
59 63
60 self.SetSizer(sizer) 64 self.SetSizer(sizer)
61 sizer.Fit(self) 65 sizer.Fit(self)
invesalius/gui/task_exporter.py
@@ -21,7 +21,12 @@ import os @@ -21,7 +21,12 @@ import os
21 import sys 21 import sys
22 22
23 import wx 23 import wx
24 -import wx.lib.hyperlink as hl 24 +
  25 +try:
  26 + import wx.lib.agw.hyperlink as hl
  27 +except ImportError:
  28 + import wx.lib.hyperlink as hl
  29 +
25 import wx.lib.platebtn as pbtn 30 import wx.lib.platebtn as pbtn
26 from wx.lib.pubsub import pub as Publisher 31 from wx.lib.pubsub import pub as Publisher
27 32
invesalius/gui/task_importer.py
@@ -20,8 +20,12 @@ import os @@ -20,8 +20,12 @@ import os
20 import sys 20 import sys
21 21
22 import wx 22 import wx
23 -import wx.lib.hyperlink as hl 23 +try:
  24 + import wx.lib.agw.hyperlink as hl
  25 +except ImportError:
  26 + import wx.lib.hyperlink as hl
24 import wx.lib.platebtn as pbtn 27 import wx.lib.platebtn as pbtn
  28 +
25 from wx.lib.pubsub import pub as Publisher 29 from wx.lib.pubsub import pub as Publisher
26 30
27 import invesalius.constants as const 31 import invesalius.constants as const
@@ -222,7 +226,7 @@ class InnerTaskPanel(wx.Panel): @@ -222,7 +226,7 @@ class InnerTaskPanel(wx.Panel):
222 226
223 227
224 def ImportPACS(self): 228 def ImportPACS(self):
225 - print "TODO: Send Signal - Import DICOM files from PACS" 229 + print("TODO: Send Signal - Import DICOM files from PACS")
226 230
227 231
228 ####### 232 #######
@@ -264,7 +268,7 @@ class InnerTaskPanel(wx.Panel): @@ -264,7 +268,7 @@ class InnerTaskPanel(wx.Panel):
264 """ 268 """
265 269
266 # Remove each project from sizer 270 # Remove each project from sizer
267 - for i in xrange(0, self.proj_count): 271 + for i in range(0, self.proj_count):
268 self.sizer.Remove(self.float_hyper_list[i]) 272 self.sizer.Remove(self.float_hyper_list[i])
269 273
270 # Delete hyperlinks 274 # Delete hyperlinks
invesalius/gui/task_navigator.py
@@ -23,9 +23,15 @@ import os @@ -23,9 +23,15 @@ import os
23 23
24 import numpy as np 24 import numpy as np
25 import wx 25 import wx
26 -import wx.lib.hyperlink as hl 26 +
  27 +try:
  28 + import wx.lib.agw.hyperlink as hl
  29 + import wx.lib.agw.foldpanelbar as fpb
  30 +except ImportError:
  31 + import wx.lib.hyperlink as hl
  32 + import wx.lib.foldpanelbar as fpb
  33 +
27 import wx.lib.masked.numctrl 34 import wx.lib.masked.numctrl
28 -import wx.lib.foldpanelbar as fpb  
29 from wx.lib.pubsub import pub as Publisher 35 from wx.lib.pubsub import pub as Publisher
30 import wx.lib.colourselect as csel 36 import wx.lib.colourselect as csel
31 import wx.lib.platebtn as pbtn 37 import wx.lib.platebtn as pbtn
@@ -42,6 +48,7 @@ import invesalius.data.trackers as dt @@ -42,6 +48,7 @@ import invesalius.data.trackers as dt
42 import invesalius.data.trigger as trig 48 import invesalius.data.trigger as trig
43 import invesalius.data.record_coords as rec 49 import invesalius.data.record_coords as rec
44 import invesalius.gui.dialogs as dlg 50 import invesalius.gui.dialogs as dlg
  51 +from invesalius import utils
45 52
46 BTN_NEW = wx.NewId() 53 BTN_NEW = wx.NewId()
47 BTN_IMPORT_LOCAL = wx.NewId() 54 BTN_IMPORT_LOCAL = wx.NewId()
@@ -114,7 +121,10 @@ class FoldPanel(wx.Panel): @@ -114,7 +121,10 @@ class FoldPanel(wx.Panel):
114 class InnerFoldPanel(wx.Panel): 121 class InnerFoldPanel(wx.Panel):
115 def __init__(self, parent): 122 def __init__(self, parent):
116 wx.Panel.__init__(self, parent) 123 wx.Panel.__init__(self, parent)
117 - default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) 124 + try:
  125 + default_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENUBAR)
  126 + except AttributeError:
  127 + default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
118 self.SetBackgroundColour(default_colour) 128 self.SetBackgroundColour(default_colour)
119 129
120 self.__bind_events() 130 self.__bind_events()
@@ -253,7 +263,10 @@ class InnerFoldPanel(wx.Panel): @@ -253,7 +263,10 @@ class InnerFoldPanel(wx.Panel):
253 class NeuronavigationPanel(wx.Panel): 263 class NeuronavigationPanel(wx.Panel):
254 def __init__(self, parent): 264 def __init__(self, parent):
255 wx.Panel.__init__(self, parent) 265 wx.Panel.__init__(self, parent)
256 - default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) 266 + try:
  267 + default_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENUBAR)
  268 + except AttributeError:
  269 + default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
257 self.SetBackgroundColour(default_colour) 270 self.SetBackgroundColour(default_colour)
258 271
259 self.SetAutoLayout(1) 272 self.SetAutoLayout(1)
@@ -300,8 +313,8 @@ class NeuronavigationPanel(wx.Panel): @@ -300,8 +313,8 @@ class NeuronavigationPanel(wx.Panel):
300 tips_img = const.TIPS_IMG 313 tips_img = const.TIPS_IMG
301 314
302 for k in btns_img: 315 for k in btns_img:
303 - n = btns_img[k].keys()[0]  
304 - lab = btns_img[k].values()[0] 316 + n = list(btns_img[k].keys())[0]
  317 + lab = list(btns_img[k].values())[0]
305 self.btns_coord[n] = wx.ToggleButton(self, k, label=lab, size=wx.Size(45, 23)) 318 self.btns_coord[n] = wx.ToggleButton(self, k, label=lab, size=wx.Size(45, 23))
306 self.btns_coord[n].SetToolTip(wx.ToolTip(tips_img[n])) 319 self.btns_coord[n].SetToolTip(wx.ToolTip(tips_img[n]))
307 self.btns_coord[n].Bind(wx.EVT_TOGGLEBUTTON, self.OnImageFiducials) 320 self.btns_coord[n].Bind(wx.EVT_TOGGLEBUTTON, self.OnImageFiducials)
@@ -311,8 +324,8 @@ class NeuronavigationPanel(wx.Panel): @@ -311,8 +324,8 @@ class NeuronavigationPanel(wx.Panel):
311 tips_trk = const.TIPS_TRK 324 tips_trk = const.TIPS_TRK
312 325
313 for k in btns_trk: 326 for k in btns_trk:
314 - n = btns_trk[k].keys()[0]  
315 - lab = btns_trk[k].values()[0] 327 + n = list(btns_trk[k].keys())[0]
  328 + lab = list(btns_trk[k].values())[0]
316 self.btns_coord[n] = wx.Button(self, k, label=lab, size=wx.Size(45, 23)) 329 self.btns_coord[n] = wx.Button(self, k, label=lab, size=wx.Size(45, 23))
317 self.btns_coord[n].SetToolTip(wx.ToolTip(tips_trk[n-3])) 330 self.btns_coord[n].SetToolTip(wx.ToolTip(tips_trk[n-3]))
318 # Exception for event of button that set image coordinates 331 # Exception for event of button that set image coordinates
@@ -393,8 +406,8 @@ class NeuronavigationPanel(wx.Panel): @@ -393,8 +406,8 @@ class NeuronavigationPanel(wx.Panel):
393 marker_id = pubsub_evt.data[0] 406 marker_id = pubsub_evt.data[0]
394 coord = pubsub_evt.data[1] 407 coord = pubsub_evt.data[1]
395 for n in const.BTNS_IMG_MKS: 408 for n in const.BTNS_IMG_MKS:
396 - btn_id = const.BTNS_IMG_MKS[n].keys()[0]  
397 - fid_id = const.BTNS_IMG_MKS[n].values()[0] 409 + btn_id = list(const.BTNS_IMG_MKS[n].keys())[0]
  410 + fid_id = list(const.BTNS_IMG_MKS[n].values())[0]
398 if marker_id == fid_id and not self.btns_coord[btn_id].GetValue(): 411 if marker_id == fid_id and not self.btns_coord[btn_id].GetValue():
399 self.btns_coord[btn_id].SetValue(True) 412 self.btns_coord[btn_id].SetValue(True)
400 self.fiducials[btn_id, :] = coord[0:3] 413 self.fiducials[btn_id, :] = coord[0:3]
@@ -461,11 +474,11 @@ class NeuronavigationPanel(wx.Panel): @@ -461,11 +474,11 @@ class NeuronavigationPanel(wx.Panel):
461 if not self.trk_init[0]: 474 if not self.trk_init[0]:
462 dlg.NavigationTrackerWarning(self.tracker_id, self.trk_init[1]) 475 dlg.NavigationTrackerWarning(self.tracker_id, self.trk_init[1])
463 ctrl.SetSelection(0) 476 ctrl.SetSelection(0)
464 - print "Tracker not connected!" 477 + print("Tracker not connected!")
465 else: 478 else:
466 Publisher.sendMessage('Update status text in GUI', _("Ready")) 479 Publisher.sendMessage('Update status text in GUI', _("Ready"))
467 ctrl.SetSelection(self.tracker_id) 480 ctrl.SetSelection(self.tracker_id)
468 - print "Tracker connected!" 481 + print("Tracker connected!")
469 elif choice == 6: 482 elif choice == 6:
470 if trck: 483 if trck:
471 Publisher.sendMessage('Update status text in GUI', _("Disconnecting tracker ...")) 484 Publisher.sendMessage('Update status text in GUI', _("Disconnecting tracker ..."))
@@ -477,10 +490,10 @@ class NeuronavigationPanel(wx.Panel): @@ -477,10 +490,10 @@ class NeuronavigationPanel(wx.Panel):
477 self.tracker_id = 0 490 self.tracker_id = 0
478 ctrl.SetSelection(self.tracker_id) 491 ctrl.SetSelection(self.tracker_id)
479 Publisher.sendMessage('Update status text in GUI', _("Tracker disconnected")) 492 Publisher.sendMessage('Update status text in GUI', _("Tracker disconnected"))
480 - print "Tracker disconnected!" 493 + print("Tracker disconnected!")
481 else: 494 else:
482 Publisher.sendMessage('Update status text in GUI', _("Tracker still connected")) 495 Publisher.sendMessage('Update status text in GUI', _("Tracker still connected"))
483 - print "Tracker still connected!" 496 + print("Tracker still connected!")
484 else: 497 else:
485 ctrl.SetSelection(self.tracker_id) 498 ctrl.SetSelection(self.tracker_id)
486 499
@@ -506,11 +519,11 @@ class NeuronavigationPanel(wx.Panel): @@ -506,11 +519,11 @@ class NeuronavigationPanel(wx.Panel):
506 # TODO: Improve the restarting of trackers after changing reference mode 519 # TODO: Improve the restarting of trackers after changing reference mode
507 # self.OnChoiceTracker(None, ctrl) 520 # self.OnChoiceTracker(None, ctrl)
508 Publisher.sendMessage('Update tracker initializer', (self.tracker_id, self.trk_init, self.ref_mode_id)) 521 Publisher.sendMessage('Update tracker initializer', (self.tracker_id, self.trk_init, self.ref_mode_id))
509 - print "Reference mode changed!" 522 + print("Reference mode changed!")
510 523
511 def OnSetImageCoordinates(self, evt): 524 def OnSetImageCoordinates(self, evt):
512 # FIXME: Cross does not update in last clicked slice, only on the other two 525 # FIXME: Cross does not update in last clicked slice, only on the other two
513 - btn_id = const.BTNS_TRK[evt.GetId()].keys()[0] 526 + btn_id = list(const.BTNS_TRK[evt.GetId()].keys())[0]
514 527
515 ux, uy, uz = self.numctrls_coord[btn_id][0].GetValue(),\ 528 ux, uy, uz = self.numctrls_coord[btn_id][0].GetValue(),\
516 self.numctrls_coord[btn_id][1].GetValue(),\ 529 self.numctrls_coord[btn_id][1].GetValue(),\
@@ -518,12 +531,12 @@ class NeuronavigationPanel(wx.Panel): @@ -518,12 +531,12 @@ class NeuronavigationPanel(wx.Panel):
518 531
519 Publisher.sendMessage('Set ball reference position', (ux, uy, uz)) 532 Publisher.sendMessage('Set ball reference position', (ux, uy, uz))
520 # Publisher.sendMessage('Set camera in volume', (ux, uy, uz)) 533 # Publisher.sendMessage('Set camera in volume', (ux, uy, uz))
521 - Publisher.sendMessage('Co-registered points', (ux, uy, uz, 0., 0., 0.)) 534 + Publisher.sendMessage('Co-registered points', ((ux, uy, uz), (0., 0., 0.)))
522 Publisher.sendMessage('Update cross position', (ux, uy, uz)) 535 Publisher.sendMessage('Update cross position', (ux, uy, uz))
523 536
524 def OnImageFiducials(self, evt): 537 def OnImageFiducials(self, evt):
525 - btn_id = const.BTNS_IMG_MKS[evt.GetId()].keys()[0]  
526 - marker_id = const.BTNS_IMG_MKS[evt.GetId()].values()[0] 538 + btn_id = list(const.BTNS_IMG_MKS[evt.GetId()].keys())[0]
  539 + marker_id = list(const.BTNS_IMG_MKS[evt.GetId()].values())[0]
527 540
528 if self.btns_coord[btn_id].GetValue(): 541 if self.btns_coord[btn_id].GetValue():
529 coord = self.numctrls_coord[btn_id][0].GetValue(),\ 542 coord = self.numctrls_coord[btn_id][0].GetValue(),\
@@ -540,7 +553,7 @@ class NeuronavigationPanel(wx.Panel): @@ -540,7 +553,7 @@ class NeuronavigationPanel(wx.Panel):
540 Publisher.sendMessage('Delete fiducial marker', marker_id) 553 Publisher.sendMessage('Delete fiducial marker', marker_id)
541 554
542 def OnTrackerFiducials(self, evt): 555 def OnTrackerFiducials(self, evt):
543 - btn_id = const.BTNS_TRK[evt.GetId()].keys()[0] 556 + btn_id = list(const.BTNS_TRK[evt.GetId()].keys())[0]
544 coord = None 557 coord = None
545 558
546 if self.trk_init and self.tracker_id: 559 if self.trk_init and self.tracker_id:
@@ -704,7 +717,10 @@ class NeuronavigationPanel(wx.Panel): @@ -704,7 +717,10 @@ class NeuronavigationPanel(wx.Panel):
704 class ObjectRegistrationPanel(wx.Panel): 717 class ObjectRegistrationPanel(wx.Panel):
705 def __init__(self, parent): 718 def __init__(self, parent):
706 wx.Panel.__init__(self, parent) 719 wx.Panel.__init__(self, parent)
707 - default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) 720 + try:
  721 + default_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENUBAR)
  722 + except AttributeError:
  723 + default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
708 self.SetBackgroundColour(default_colour) 724 self.SetBackgroundColour(default_colour)
709 725
710 self.coil_list = const.COIL 726 self.coil_list = const.COIL
@@ -917,7 +933,7 @@ class ObjectRegistrationPanel(wx.Panel): @@ -917,7 +933,7 @@ class ObjectRegistrationPanel(wx.Panel):
917 else: 933 else:
918 filename = dlg.ShowSaveRegistrationDialog("object_registration.obr") 934 filename = dlg.ShowSaveRegistrationDialog("object_registration.obr")
919 if filename: 935 if filename:
920 - hdr = 'Object' + "\t" + self.obj_name + "\t" + 'Reference' + "\t" + str('%d' % self.obj_ref_mode) 936 + hdr = 'Object' + "\t" + utils.decode(self.obj_name, const.FS_ENCODE) + "\t" + 'Reference' + "\t" + str('%d' % self.obj_ref_mode)
921 data = np.hstack([self.obj_fiducials, self.obj_orients]) 937 data = np.hstack([self.obj_fiducials, self.obj_orients])
922 np.savetxt(filename, data, fmt='%.4f', delimiter='\t', newline='\n', header=hdr) 938 np.savetxt(filename, data, fmt='%.4f', delimiter='\t', newline='\n', header=hdr)
923 wx.MessageBox(_("Object file successfully saved"), _("Save")) 939 wx.MessageBox(_("Object file successfully saved"), _("Save"))
@@ -939,7 +955,10 @@ class ObjectRegistrationPanel(wx.Panel): @@ -939,7 +955,10 @@ class ObjectRegistrationPanel(wx.Panel):
939 class MarkersPanel(wx.Panel): 955 class MarkersPanel(wx.Panel):
940 def __init__(self, parent): 956 def __init__(self, parent):
941 wx.Panel.__init__(self, parent) 957 wx.Panel.__init__(self, parent)
942 - default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) 958 + try:
  959 + default_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENUBAR)
  960 + except AttributeError:
  961 + default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
943 self.SetBackgroundColour(default_colour) 962 self.SetBackgroundColour(default_colour)
944 963
945 self.SetAutoLayout(1) 964 self.SetAutoLayout(1)
@@ -1137,7 +1156,7 @@ class MarkersPanel(wx.Panel): @@ -1137,7 +1156,7 @@ class MarkersPanel(wx.Panel):
1137 item = self.lc.GetItem(id_n, 4) 1156 item = self.lc.GetItem(id_n, 4)
1138 if item.GetText() == marker_id: 1157 if item.GetText() == marker_id:
1139 for i in const.BTNS_IMG_MKS: 1158 for i in const.BTNS_IMG_MKS:
1140 - if marker_id in const.BTNS_IMG_MKS[i].values()[0]: 1159 + if marker_id in list(const.BTNS_IMG_MKS[i].values())[0]:
1141 self.lc.Focus(item.GetId()) 1160 self.lc.Focus(item.GetId())
1142 index = [self.lc.GetFocusedItem()] 1161 index = [self.lc.GetFocusedItem()]
1143 else: 1162 else:
@@ -1192,7 +1211,7 @@ class MarkersPanel(wx.Panel): @@ -1192,7 +1211,7 @@ class MarkersPanel(wx.Panel):
1192 1211
1193 if len(line) == 11: 1212 if len(line) == 11:
1194 for i in const.BTNS_IMG_MKS: 1213 for i in const.BTNS_IMG_MKS:
1195 - if line[10] in const.BTNS_IMG_MKS[i].values()[0]: 1214 + if line[10] in list(const.BTNS_IMG_MKS[i].values())[0]:
1196 Publisher.sendMessage('Load image fiducials', (line[10], coord)) 1215 Publisher.sendMessage('Load image fiducials', (line[10], coord))
1197 elif line[10] == 'TARGET': 1216 elif line[10] == 'TARGET':
1198 target = count_line 1217 target = count_line
@@ -1210,7 +1229,7 @@ class MarkersPanel(wx.Panel): @@ -1210,7 +1229,7 @@ class MarkersPanel(wx.Panel):
1210 1229
1211 if len(line) == 8: 1230 if len(line) == 8:
1212 for i in const.BTNS_IMG_MKS: 1231 for i in const.BTNS_IMG_MKS:
1213 - if line[7] in const.BTNS_IMG_MKS[i].values()[0]: 1232 + if line[7] in list(const.BTNS_IMG_MKS[i].values())[0]:
1214 Publisher.sendMessage('Load image fiducials', (line[7], coord)) 1233 Publisher.sendMessage('Load image fiducials', (line[7], coord))
1215 else: 1234 else:
1216 line.append("") 1235 line.append("")
invesalius/gui/task_slice.py
@@ -21,9 +21,15 @@ import sys @@ -21,9 +21,15 @@ import sys
21 import os 21 import os
22 22
23 import wx 23 import wx
24 -import wx.lib.hyperlink as hl 24 +
  25 +try:
  26 + import wx.lib.agw.hyperlink as hl
  27 + import wx.lib.agw.foldpanelbar as fpb
  28 +except ImportError:
  29 + import wx.lib.hyperlink as hl
  30 + import wx.lib.foldpanelbar as fpb
  31 +
25 import wx.lib.platebtn as pbtn 32 import wx.lib.platebtn as pbtn
26 -import wx.lib.foldpanelbar as fpb  
27 import wx.lib.colourselect as csel 33 import wx.lib.colourselect as csel
28 from wx.lib.pubsub import pub as Publisher 34 from wx.lib.pubsub import pub as Publisher
29 35
@@ -110,7 +116,10 @@ class InnerTaskPanel(wx.Panel): @@ -110,7 +116,10 @@ class InnerTaskPanel(wx.Panel):
110 #print wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) 116 #print wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
111 #print wx.SystemSettings_GetColour(wx.SYS_COLOUR_SCROLLBAR) 117 #print wx.SystemSettings_GetColour(wx.SYS_COLOUR_SCROLLBAR)
112 #print wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUHILIGHT) 118 #print wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUHILIGHT)
113 - default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) 119 + try:
  120 + default_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENUBAR)
  121 + except AttributeError:
  122 + default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
114 fold_panel = FoldPanel(self) 123 fold_panel = FoldPanel(self)
115 fold_panel.SetBackgroundColour(default_colour) 124 fold_panel.SetBackgroundColour(default_colour)
116 self.fold_panel = fold_panel 125 self.fold_panel = fold_panel
@@ -136,7 +145,7 @@ class InnerTaskPanel(wx.Panel): @@ -136,7 +145,7 @@ class InnerTaskPanel(wx.Panel):
136 main_sizer = wx.BoxSizer(wx.VERTICAL) 145 main_sizer = wx.BoxSizer(wx.VERTICAL)
137 main_sizer.Add(line_new, 0,wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5) 146 main_sizer.Add(line_new, 0,wx.GROW|wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5)
138 main_sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND|wx.ALL, 5) 147 main_sizer.Add(fold_panel, 1, wx.GROW|wx.EXPAND|wx.ALL, 5)
139 - main_sizer.AddSizer(line_sizer, 0, wx.GROW|wx.EXPAND) 148 + main_sizer.Add(line_sizer, 0, wx.GROW|wx.EXPAND)
140 main_sizer.AddSpacer(5) 149 main_sizer.AddSpacer(5)
141 main_sizer.Fit(self) 150 main_sizer.Fit(self)
142 151
@@ -238,7 +247,10 @@ class FoldPanel(wx.Panel): @@ -238,7 +247,10 @@ class FoldPanel(wx.Panel):
238 class InnerFoldPanel(wx.Panel): 247 class InnerFoldPanel(wx.Panel):
239 def __init__(self, parent): 248 def __init__(self, parent):
240 wx.Panel.__init__(self, parent) 249 wx.Panel.__init__(self, parent)
241 - default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) 250 + try:
  251 + default_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENUBAR)
  252 + except AttributeError:
  253 + default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
242 self.SetBackgroundColour(default_colour) 254 self.SetBackgroundColour(default_colour)
243 255
244 # Fold panel and its style settings 256 # Fold panel and its style settings
@@ -508,10 +520,10 @@ class MaskProperties(wx.Panel): @@ -508,10 +520,10 @@ class MaskProperties(wx.Panel):
508 520
509 def CloseProject(self): 521 def CloseProject(self):
510 n = self.combo_mask_name.GetCount() 522 n = self.combo_mask_name.GetCount()
511 - for i in xrange(n-1, -1, -1): 523 + for i in range(n-1, -1, -1):
512 self.combo_mask_name.Delete(i) 524 self.combo_mask_name.Delete(i)
513 n = self.combo_thresh.GetCount() 525 n = self.combo_thresh.GetCount()
514 - for i in xrange(n-1, -1, -1): 526 + for i in range(n-1, -1, -1):
515 self.combo_thresh.Delete(i) 527 self.combo_thresh.Delete(i)
516 528
517 def OnRemoveMasks(self, pubsub_evt): 529 def OnRemoveMasks(self, pubsub_evt):
@@ -659,14 +671,17 @@ class MaskProperties(wx.Panel): @@ -659,14 +671,17 @@ class MaskProperties(wx.Panel):
659 session.ChangeProject() 671 session.ChangeProject()
660 672
661 def OnSelectColour(self, evt): 673 def OnSelectColour(self, evt):
662 - colour = evt.GetValue() 674 + colour = evt.GetValue()[:3]
663 self.gradient.SetColour(colour) 675 self.gradient.SetColour(colour)
664 Publisher.sendMessage('Change mask colour', colour) 676 Publisher.sendMessage('Change mask colour', colour)
665 677
666 class EditionTools(wx.Panel): 678 class EditionTools(wx.Panel):
667 def __init__(self, parent): 679 def __init__(self, parent):
668 wx.Panel.__init__(self, parent) 680 wx.Panel.__init__(self, parent)
669 - default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) 681 + try:
  682 + default_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENUBAR)
  683 + except AttributeError:
  684 + default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
670 self.SetBackgroundColour(default_colour) 685 self.SetBackgroundColour(default_colour)
671 686
672 ## LINE 1 687 ## LINE 1
@@ -830,7 +845,10 @@ class EditionTools(wx.Panel): @@ -830,7 +845,10 @@ class EditionTools(wx.Panel):
830 class WatershedTool(EditionTools): 845 class WatershedTool(EditionTools):
831 def __init__(self, parent): 846 def __init__(self, parent):
832 wx.Panel.__init__(self, parent) 847 wx.Panel.__init__(self, parent)
833 - default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) 848 + try:
  849 + default_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENUBAR)
  850 + except AttributeError:
  851 + default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
834 self.SetBackgroundColour(default_colour) 852 self.SetBackgroundColour(default_colour)
835 853
836 ## LINE 1 854 ## LINE 1
invesalius/gui/task_surface.py
@@ -20,9 +20,15 @@ import sys @@ -20,9 +20,15 @@ import sys
20 import os 20 import os
21 21
22 import wx 22 import wx
23 -import wx.lib.hyperlink as hl 23 +
  24 +try:
  25 + import wx.lib.agw.hyperlink as hl
  26 + import wx.lib.agw.foldpanelbar as fpb
  27 +except ImportError:
  28 + import wx.lib.hyperlink as hl
  29 + import wx.lib.foldpanelbar as fpb
  30 +
24 from wx.lib.pubsub import pub as Publisher 31 from wx.lib.pubsub import pub as Publisher
25 -import wx.lib.foldpanelbar as fpb  
26 import wx.lib.colourselect as csel 32 import wx.lib.colourselect as csel
27 33
28 import invesalius.constants as const 34 import invesalius.constants as const
@@ -211,7 +217,10 @@ class FoldPanel(wx.Panel): @@ -211,7 +217,10 @@ class FoldPanel(wx.Panel):
211 class InnerFoldPanel(wx.Panel): 217 class InnerFoldPanel(wx.Panel):
212 def __init__(self, parent): 218 def __init__(self, parent):
213 wx.Panel.__init__(self, parent) 219 wx.Panel.__init__(self, parent)
214 - default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) 220 + try:
  221 + default_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENUBAR)
  222 + except AttributeError:
  223 + default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
215 self.SetBackgroundColour(default_colour) 224 self.SetBackgroundColour(default_colour)
216 225
217 # Fold panel and its style settings 226 # Fold panel and its style settings
@@ -280,7 +289,10 @@ BTN_SEEDS = wx.NewId() @@ -280,7 +289,10 @@ BTN_SEEDS = wx.NewId()
280 class SurfaceTools(wx.Panel): 289 class SurfaceTools(wx.Panel):
281 def __init__(self, parent): 290 def __init__(self, parent):
282 wx.Panel.__init__(self, parent) 291 wx.Panel.__init__(self, parent)
283 - default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) 292 + try:
  293 + default_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENUBAR)
  294 + except AttributeError:
  295 + default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
284 self.SetBackgroundColour(default_colour) 296 self.SetBackgroundColour(default_colour)
285 297
286 #self.SetBackgroundColour(wx.Colour(255,255,255)) 298 #self.SetBackgroundColour(wx.Colour(255,255,255))
@@ -411,12 +423,12 @@ class SurfaceTools(wx.Panel): @@ -411,12 +423,12 @@ class SurfaceTools(wx.Panel):
411 self.EndSeeding() 423 self.EndSeeding()
412 424
413 def StartSeeding(self): 425 def StartSeeding(self):
414 - print "Start Seeding" 426 + print("Start Seeding")
415 Publisher.sendMessage('Enable style', const.VOLUME_STATE_SEED) 427 Publisher.sendMessage('Enable style', const.VOLUME_STATE_SEED)
416 Publisher.sendMessage('Create surface by seeding - start') 428 Publisher.sendMessage('Create surface by seeding - start')
417 429
418 def EndSeeding(self): 430 def EndSeeding(self):
419 - print "End Seeding" 431 + print("End Seeding")
420 Publisher.sendMessage('Disable style', const.VOLUME_STATE_SEED) 432 Publisher.sendMessage('Disable style', const.VOLUME_STATE_SEED)
421 Publisher.sendMessage('Create surface by seeding - end') 433 Publisher.sendMessage('Create surface by seeding - end')
422 434
@@ -425,7 +437,10 @@ class SurfaceTools(wx.Panel): @@ -425,7 +437,10 @@ class SurfaceTools(wx.Panel):
425 class SurfaceProperties(wx.Panel): 437 class SurfaceProperties(wx.Panel):
426 def __init__(self, parent): 438 def __init__(self, parent):
427 wx.Panel.__init__(self, parent) 439 wx.Panel.__init__(self, parent)
428 - default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) 440 + try:
  441 + default_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENUBAR)
  442 + except AttributeError:
  443 + default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
429 self.SetBackgroundColour(default_colour) 444 self.SetBackgroundColour(default_colour)
430 445
431 self.surface_list = [] 446 self.surface_list = []
@@ -526,7 +541,7 @@ class SurfaceProperties(wx.Panel): @@ -526,7 +541,7 @@ class SurfaceProperties(wx.Panel):
526 541
527 def CloseProject(self): 542 def CloseProject(self):
528 n = self.combo_surface_name.GetCount() 543 n = self.combo_surface_name.GetCount()
529 - for i in xrange(n-1, -1, -1): 544 + for i in range(n-1, -1, -1):
530 self.combo_surface_name.Delete(i) 545 self.combo_surface_name.Delete(i)
531 self.surface_list = [] 546 self.surface_list = []
532 547
@@ -587,7 +602,10 @@ class QualityAdjustment(wx.Panel): @@ -587,7 +602,10 @@ class QualityAdjustment(wx.Panel):
587 def __init__(self, parent): 602 def __init__(self, parent):
588 import invesalius.constants as const 603 import invesalius.constants as const
589 wx.Panel.__init__(self, parent) 604 wx.Panel.__init__(self, parent)
590 - default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR) 605 + try:
  606 + default_colour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENUBAR)
  607 + except AttributeError:
  608 + default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
591 self.SetBackgroundColour(default_colour) 609 self.SetBackgroundColour(default_colour)
592 610
593 # LINE 1 611 # LINE 1
@@ -643,7 +661,7 @@ class QualityAdjustment(wx.Panel): @@ -643,7 +661,7 @@ class QualityAdjustment(wx.Panel):
643 self.SetAutoLayout(1) 661 self.SetAutoLayout(1)
644 662
645 def OnComboQuality(self, evt): 663 def OnComboQuality(self, evt):
646 - print "TODO: Send Signal - Change surface quality: %s" % (evt.GetString()) 664 + print("TODO: Send Signal - Change surface quality: %s" % (evt.GetString()))
647 665
648 def OnDecimate(self, evt): 666 def OnDecimate(self, evt):
649 - print "TODO: Send Signal - Decimate: %s" % float(self.spin.GetValue())/100 667 + print("TODO: Send Signal - Decimate: %s" % float(self.spin.GetValue())/100)
invesalius/gui/task_tools.py
@@ -20,7 +20,12 @@ @@ -20,7 +20,12 @@
20 import wx 20 import wx
21 import os 21 import os
22 import wx.lib.embeddedimage as emb 22 import wx.lib.embeddedimage as emb
23 -import wx.lib.hyperlink as hl 23 +
  24 +try:
  25 + import wx.lib.agw.hyperlink as hl
  26 +except ImportError:
  27 + import wx.lib.hyperlink as hl
  28 +
24 import wx.lib.platebtn as pbtn 29 import wx.lib.platebtn as pbtn
25 from wx.lib.pubsub import pub as Publisher 30 from wx.lib.pubsub import pub as Publisher
26 31
@@ -120,7 +125,7 @@ class InnerTaskPanel(wx.Panel): @@ -120,7 +125,7 @@ class InnerTaskPanel(wx.Panel):
120 self.sizer = main_sizer 125 self.sizer = main_sizer
121 126
122 def OnTextAnnotation(self, evt=None): 127 def OnTextAnnotation(self, evt=None):
123 - print "TODO: Send Signal - Add text annotation (both 2d and 3d)" 128 + print("TODO: Send Signal - Add text annotation (both 2d and 3d)")
124 129
125 def OnLinkLinearMeasure(self): 130 def OnLinkLinearMeasure(self):
126 Publisher.sendMessage('Enable style', 131 Publisher.sendMessage('Enable style',
invesalius/gui/widgets/clut_imagedata.py
  1 +import functools
1 import math 2 import math
2 import wx 3 import wx
3 4
@@ -33,6 +34,7 @@ myEVT_CLUT_NODE_CHANGED = wx.NewEventType() @@ -33,6 +34,7 @@ myEVT_CLUT_NODE_CHANGED = wx.NewEventType()
33 EVT_CLUT_NODE_CHANGED = wx.PyEventBinder(myEVT_CLUT_NODE_CHANGED, 1) 34 EVT_CLUT_NODE_CHANGED = wx.PyEventBinder(myEVT_CLUT_NODE_CHANGED, 1)
34 35
35 36
  37 +@functools.total_ordering
36 class Node(object): 38 class Node(object):
37 def __init__(self, value, colour): 39 def __init__(self, value, colour):
38 self.value = value 40 self.value = value
@@ -41,6 +43,12 @@ class Node(object): @@ -41,6 +43,12 @@ class Node(object):
41 def __cmp__(self, o): 43 def __cmp__(self, o):
42 return cmp(self.value, o.value) 44 return cmp(self.value, o.value)
43 45
  46 + def __lt__(self, other):
  47 + return self.value < other.value
  48 +
  49 + def __eq__(self, other):
  50 + return self.value == other.value
  51 +
44 def __repr__(self): 52 def __repr__(self):
45 return "(%d %s)" % (self.value, self.colour) 53 return "(%d %s)" % (self.value, self.colour)
46 54
@@ -147,7 +155,7 @@ class CLUTImageDataWidget(wx.Panel): @@ -147,7 +155,7 @@ class CLUTImageDataWidget(wx.Panel):
147 prop_y = (h) * 1.0 / (y_end - y_init) 155 prop_y = (h) * 1.0 / (y_end - y_init)
148 156
149 self._d_hist = [] 157 self._d_hist = []
150 - for i in xrange(w): 158 + for i in range(w):
151 x = i / prop_x + x_init - 1 159 x = i / prop_x + x_init - 1
152 if self.i_init <= x < self.i_end: 160 if self.i_init <= x < self.i_end:
153 try: 161 try:
@@ -218,7 +226,7 @@ class CLUTImageDataWidget(wx.Panel): @@ -218,7 +226,7 @@ class CLUTImageDataWidget(wx.Panel):
218 self.middle_pressed = False 226 self.middle_pressed = False
219 227
220 def OnClick(self, evt): 228 def OnClick(self, evt):
221 - px, py = evt.GetPositionTuple() 229 + px, py = evt.GetPosition()
222 self.left_pressed = True 230 self.left_pressed = True
223 self.selected_node = self.get_node_clicked(px, py) 231 self.selected_node = self.get_node_clicked(px, py)
224 self.last_selected = self.selected_node 232 self.last_selected = self.selected_node
@@ -231,7 +239,7 @@ class CLUTImageDataWidget(wx.Panel): @@ -231,7 +239,7 @@ class CLUTImageDataWidget(wx.Panel):
231 239
232 def OnDoubleClick(self, evt): 240 def OnDoubleClick(self, evt):
233 w, h = self.GetVirtualSize() 241 w, h = self.GetVirtualSize()
234 - px, py = evt.GetPositionTuple() 242 + px, py = evt.GetPosition()
235 243
236 # Verifying if the user double-click in a node-colour. 244 # Verifying if the user double-click in a node-colour.
237 selected_node = self.get_node_clicked(px, py) 245 selected_node = self.get_node_clicked(px, py)
@@ -240,7 +248,7 @@ class CLUTImageDataWidget(wx.Panel): @@ -240,7 +248,7 @@ class CLUTImageDataWidget(wx.Panel):
240 # option to change the color from this node. 248 # option to change the color from this node.
241 colour_dialog = wx.GetColourFromUser(self, (0, 0, 0)) 249 colour_dialog = wx.GetColourFromUser(self, (0, 0, 0))
242 if colour_dialog.IsOk(): 250 if colour_dialog.IsOk():
243 - r, g, b = colour_dialog.Get() 251 + r, g, b = colour_dialog.Get()[:3]
244 selected_node.colour = r, g, b 252 selected_node.colour = r, g, b
245 self._generate_event() 253 self._generate_event()
246 else: 254 else:
@@ -255,7 +263,7 @@ class CLUTImageDataWidget(wx.Panel): @@ -255,7 +263,7 @@ class CLUTImageDataWidget(wx.Panel):
255 263
256 def OnRightClick(self, evt): 264 def OnRightClick(self, evt):
257 w, h = self.GetVirtualSize() 265 w, h = self.GetVirtualSize()
258 - px, py = evt.GetPositionTuple() 266 + px, py = evt.GetPosition()
259 selected_node = self.get_node_clicked(px, py) 267 selected_node = self.get_node_clicked(px, py)
260 268
261 if selected_node: 269 if selected_node:
invesalius/gui/widgets/clut_raycasting.py
@@ -97,8 +97,8 @@ class Button(object): @@ -97,8 +97,8 @@ class Button(object):
97 """ 97 """
98 Test if the button was clicked. 98 Test if the button was clicked.
99 """ 99 """
100 - print self.position  
101 - print self.size 100 + print(self.position)
  101 + print(self.size)
102 m_x, m_y = position 102 m_x, m_y = position
103 i_x, i_y = self.position 103 i_x, i_y = self.position
104 w, h = self.size 104 w, h = self.size
@@ -146,7 +146,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -146,7 +146,7 @@ class CLUTRaycastingWidget(wx.Panel):
146 Se the range from hounsfield 146 Se the range from hounsfield
147 """ 147 """
148 self.init, self.end = range 148 self.init, self.end = range
149 - print "Range", range 149 + print("Range", range)
150 self.CalculatePixelPoints() 150 self.CalculatePixelPoints()
151 151
152 def SetPadding(self, padding): 152 def SetPadding(self, padding):
@@ -169,9 +169,9 @@ class CLUTRaycastingWidget(wx.Panel): @@ -169,9 +169,9 @@ class CLUTRaycastingWidget(wx.Panel):
169 pass 169 pass
170 170
171 def OnClick(self, evt): 171 def OnClick(self, evt):
172 - x, y = evt.GetPositionTuple()  
173 - if self.save_button.HasClicked(evt.GetPositionTuple()):  
174 - print "Salvando" 172 + x, y = evt.GetPosition()
  173 + if self.save_button.HasClicked((x, y)):
  174 + print("Salvando")
175 filename = dialog.ShowSavePresetDialog() 175 filename = dialog.ShowSavePresetDialog()
176 if filename: 176 if filename:
177 Publisher.sendMessage('Save raycasting preset', filename) 177 Publisher.sendMessage('Save raycasting preset', filename)
@@ -218,7 +218,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -218,7 +218,7 @@ class CLUTRaycastingWidget(wx.Panel):
218 """ 218 """
219 Used to change the colour of a point 219 Used to change the colour of a point
220 """ 220 """
221 - point = self._has_clicked_in_a_point(evt.GetPositionTuple()) 221 + point = self._has_clicked_in_a_point(evt.GetPosition())
222 if point: 222 if point:
223 i, j = point 223 i, j = point
224 actual_colour = self.curves[i].nodes[j].colour 224 actual_colour = self.curves[i].nodes[j].colour
@@ -240,18 +240,18 @@ class CLUTRaycastingWidget(wx.Panel): @@ -240,18 +240,18 @@ class CLUTRaycastingWidget(wx.Panel):
240 """ 240 """
241 Used to remove a point 241 Used to remove a point
242 """ 242 """
243 - point = self._has_clicked_in_a_point(evt.GetPositionTuple()) 243 + point = self._has_clicked_in_a_point(evt.GetPosition())
244 if point: 244 if point:
245 i, j = point 245 i, j = point
246 - print "RightClick", i, j 246 + print("RightClick", i, j)
247 self.RemovePoint(i, j) 247 self.RemovePoint(i, j)
248 self.Refresh() 248 self.Refresh()
249 nevt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), i) 249 nevt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), i)
250 self.GetEventHandler().ProcessEvent(nevt) 250 self.GetEventHandler().ProcessEvent(nevt)
251 return 251 return
252 - n_curve = self._has_clicked_in_selection_curve(evt.GetPositionTuple()) 252 + n_curve = self._has_clicked_in_selection_curve(evt.GetPosition())
253 if n_curve is not None: 253 if n_curve is not None:
254 - print "Removing a curve" 254 + print("Removing a curve")
255 self.RemoveCurve(n_curve) 255 self.RemoveCurve(n_curve)
256 self.Refresh() 256 self.Refresh()
257 nevt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), n_curve) 257 nevt = CLUTEvent(myEVT_CLUT_POINT_RELEASE, self.GetId(), n_curve)
@@ -280,7 +280,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -280,7 +280,7 @@ class CLUTRaycastingWidget(wx.Panel):
280 direction = evt.GetWheelRotation() / evt.GetWheelDelta() 280 direction = evt.GetWheelRotation() / evt.GetWheelDelta()
281 init = self.init - RANGE * direction 281 init = self.init - RANGE * direction
282 end = self.end + RANGE * direction 282 end = self.end + RANGE * direction
283 - print direction, init, end 283 + print(direction, init, end)
284 self.SetRange((init, end)) 284 self.SetRange((init, end))
285 self.Refresh() 285 self.Refresh()
286 286
@@ -369,7 +369,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -369,7 +369,7 @@ class CLUTRaycastingWidget(wx.Panel):
369 369
370 def _has_clicked_in_save(self, clicked_point): 370 def _has_clicked_in_save(self, clicked_point):
371 x, y = clicked_point 371 x, y = clicked_point
372 - print x, y 372 + print(x, y)
373 if self.padding < x < self.padding + 24 and \ 373 if self.padding < x < self.padding + 24 and \
374 self.padding < y < self.padding + 24: 374 self.padding < y < self.padding + 24:
375 return True 375 return True
@@ -559,7 +559,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -559,7 +559,7 @@ class CLUTRaycastingWidget(wx.Panel):
559 def _draw_histogram(self, ctx, height): 559 def _draw_histogram(self, ctx, height):
560 # The histogram 560 # The histogram
561 x,y = self.Histogram.points[0] 561 x,y = self.Histogram.points[0]
562 - print "=>", x,y 562 + print("=>", x,y)
563 563
564 ctx.SetPen(wx.Pen(HISTOGRAM_LINE_COLOUR, HISTOGRAM_LINE_WIDTH)) 564 ctx.SetPen(wx.Pen(HISTOGRAM_LINE_COLOUR, HISTOGRAM_LINE_WIDTH))
565 ctx.SetBrush(wx.Brush(HISTOGRAM_FILL_COLOUR)) 565 ctx.SetBrush(wx.Brush(HISTOGRAM_FILL_COLOUR))
@@ -567,7 +567,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -567,7 +567,7 @@ class CLUTRaycastingWidget(wx.Panel):
567 path = ctx.CreatePath() 567 path = ctx.CreatePath()
568 path.MoveToPoint(x,y) 568 path.MoveToPoint(x,y)
569 for x,y in self.Histogram.points: 569 for x,y in self.Histogram.points:
570 - print x,y 570 + print(x,y)
571 path.AddLineToPoint(x, y) 571 path.AddLineToPoint(x, y)
572 572
573 ctx.PushState() 573 ctx.PushState()
@@ -624,7 +624,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -624,7 +624,7 @@ class CLUTRaycastingWidget(wx.Panel):
624 proportion_x = width * 1.0 / (x_end - x_init) 624 proportion_x = width * 1.0 / (x_end - x_init)
625 proportion_y = height * 1.0 / (y_end - y_init) 625 proportion_y = height * 1.0 / (y_end - y_init)
626 self.Histogram.points = [] 626 self.Histogram.points = []
627 - for i in xrange(0, len(self.histogram_array), 5): 627 + for i in range(0, len(self.histogram_array), 5):
628 if self.histogram_array[i]: 628 if self.histogram_array[i]:
629 y = math.log(self.histogram_array[i]) 629 y = math.log(self.histogram_array[i])
630 else: 630 else:
@@ -649,7 +649,7 @@ class CLUTRaycastingWidget(wx.Panel): @@ -649,7 +649,7 @@ class CLUTRaycastingWidget(wx.Panel):
649 """ 649 """
650 for n, (point, colour) in enumerate(zip(self.points, self.colours)): 650 for n, (point, colour) in enumerate(zip(self.points, self.colours)):
651 point_colour = zip(point, colour) 651 point_colour = zip(point, colour)
652 - point_colour.sort(key=lambda x: x[0]['x']) 652 + point_colour = sorted(point_colour, key=lambda x: x[0]['x'])
653 self.points[n] = [i[0] for i in point_colour] 653 self.points[n] = [i[0] for i in point_colour]
654 self.colours[n] = [i[1] for i in point_colour] 654 self.colours[n] = [i[1] for i in point_colour]
655 655
invesalius/gui/widgets/gradient.py
@@ -121,8 +121,11 @@ class GradientSlider(wx.Panel): @@ -121,8 +121,11 @@ class GradientSlider(wx.Panel):
121 dc.GradientFillLinear((x_init_gradient, y_init_gradient, 121 dc.GradientFillLinear((x_init_gradient, y_init_gradient,
122 width_gradient, height_gradient), 122 width_gradient, height_gradient),
123 (0, 0, 0), (255,255, 255)) 123 (0, 0, 0), (255,255, 255))
124 -  
125 - n = wx.RendererNative_Get() 124 +
  125 + try:
  126 + n = wx.RendererNative.Get()
  127 + except AttributeError:
  128 + n = wx.RendererNative_Get()
126 129
127 # Drawing the push buttons 130 # Drawing the push buttons
128 n.DrawPushButton(self, dc, (x_init_push1, 0, PUSH_WIDTH, h)) 131 n.DrawPushButton(self, dc, (x_init_push1, 0, PUSH_WIDTH, h))
@@ -327,7 +330,7 @@ class GradientCtrl(wx.Panel): @@ -327,7 +330,7 @@ class GradientCtrl(wx.Panel):
327 self.max_range = maxRange 330 self.max_range = maxRange
328 self.minimun = minValue 331 self.minimun = minValue
329 self.maximun = maxValue 332 self.maximun = maxValue
330 - self.colour = colour 333 + self.colour = colour[:3]
331 self.changed = False 334 self.changed = False
332 self._draw_controls() 335 self._draw_controls()
333 self._bind_events_wx() 336 self._bind_events_wx()
@@ -433,7 +436,7 @@ class GradientCtrl(wx.Panel): @@ -433,7 +436,7 @@ class GradientCtrl(wx.Panel):
433 self._GenerateEvent(myEVT_THRESHOLD_CHANGING) 436 self._GenerateEvent(myEVT_THRESHOLD_CHANGING)
434 437
435 def SetColour(self, colour): 438 def SetColour(self, colour):
436 - colour = list(colour) + [90,] 439 + colour = list(colour[:3]) + [90,]
437 self.colour = colour 440 self.colour = colour
438 self.gradient_slider.SetColour(colour) 441 self.gradient_slider.SetColour(colour)
439 self.gradient_slider.Refresh() 442 self.gradient_slider.Refresh()
invesalius/gui/widgets/listctrl.py
@@ -63,7 +63,7 @@ class ColumnSorterMixin: @@ -63,7 +63,7 @@ class ColumnSorterMixin:
63 self.SetColumnCount(numColumns) 63 self.SetColumnCount(numColumns)
64 list = self.GetListCtrl() 64 list = self.GetListCtrl()
65 if not list: 65 if not list:
66 - raise ValueError, "No wx.ListCtrl available" 66 + raise ValueError("No wx.ListCtrl available")
67 list.Bind(wx.EVT_LIST_COL_CLICK, self.__OnColClick, list) 67 list.Bind(wx.EVT_LIST_COL_CLICK, self.__OnColClick, list)
68 68
69 69
invesalius/gui/widgets/slice_menu.py
@@ -183,17 +183,17 @@ class SliceMenu(wx.Menu): @@ -183,17 +183,17 @@ class SliceMenu(wx.Menu):
183 183
184 def FirstItemSelect(self, pusub_evt): 184 def FirstItemSelect(self, pusub_evt):
185 item = self.ID_TO_TOOL_ITEM[self.id_wl_first] 185 item = self.ID_TO_TOOL_ITEM[self.id_wl_first]
186 - item.Check(1) 186 + item.Check(True)
187 187
188 for i in self.pseudo_color_items: 188 for i in self.pseudo_color_items:
189 it = self.pseudo_color_items[i] 189 it = self.pseudo_color_items[i]
190 if it.IsChecked(): 190 if it.IsChecked():
191 - it.Toggle() 191 + it.Check(False)
192 item = self.ID_TO_TOOL_ITEM[self.id_pseudo_first] 192 item = self.ID_TO_TOOL_ITEM[self.id_pseudo_first]
193 - item.Check(1) 193 + item.Check(True)
194 194
195 - item = self.ID_TO_TOOL_ITEM[self.id_tiling_first]  
196 - item.Check(1) 195 + # item = self.ID_TO_TOOL_ITEM[self.id_tiling_first]
  196 + # item.Check(True)
197 197
198 def CheckWindowLevelOther(self, pubsub_evt): 198 def CheckWindowLevelOther(self, pubsub_evt):
199 item = self.ID_TO_TOOL_ITEM[self.other_wl_id] 199 item = self.ID_TO_TOOL_ITEM[self.other_wl_id]
invesalius/i18n.py
@@ -83,6 +83,10 @@ def InstallLanguage(language): @@ -83,6 +83,10 @@ def InstallLanguage(language):
83 83
84 lang = gettext.translation('invesalius', language_dir,\ 84 lang = gettext.translation('invesalius', language_dir,\
85 languages=[language], codeset='utf8') 85 languages=[language], codeset='utf8')
86 - # Using unicode  
87 - lang.install(unicode=1)  
88 - return lang.ugettext 86 + # Using unicode
  87 + try:
  88 + lang.install(unicode=1)
  89 + return lang.ugettext
  90 + except TypeError:
  91 + lang.install()
  92 + return lang.gettext
invesalius/net/dicom.py
@@ -165,14 +165,14 @@ class DicomNet: @@ -165,14 +165,14 @@ class DicomNet:
165 const char *call=NULL, 165 const char *call=NULL,
166 const char *outputdir=NULL)""" 166 const char *outputdir=NULL)"""
167 167
168 - print ">>>>>", self.address, int(self.port), theQuery, 11112, self.aetitle,\  
169 - self.aetitle_call, "/home/phamorim/Desktop/output/" 168 + print(">>>>>", self.address, int(self.port), theQuery, 11112, self.aetitle,
  169 + self.aetitle_call, "/home/phamorim/Desktop/output/")
170 170
171 171
172 cnf.CMove(self.address, int(self.port), theQuery, 11112, self.aetitle,\ 172 cnf.CMove(self.address, int(self.port), theQuery, 11112, self.aetitle,\
173 self.aetitle_call, "/home/phamorim/Desktop/") 173 self.aetitle_call, "/home/phamorim/Desktop/")
174 174
175 - print "BAIXOUUUUUUUU" 175 + print("BAIXOUUUUUUUU")
176 #ret = gdcm.DataSetArrayType() 176 #ret = gdcm.DataSetArrayType()
177 177
178 #cnf.CFind(self.address, int(self.port), theQuery, ret, self.aetitle,\ 178 #cnf.CFind(self.address, int(self.port), theQuery, ret, self.aetitle,\
invesalius/presets.py
@@ -43,7 +43,7 @@ class Presets(): @@ -43,7 +43,7 @@ class Presets():
43 _("Fat Tissue (Child)"):(-212,-72), 43 _("Fat Tissue (Child)"):(-212,-72),
44 _("Skin Tissue (Adult)"):(-718,-177), 44 _("Skin Tissue (Adult)"):(-718,-177),
45 _("Skin Tissue (Child)"):(-766,-202), 45 _("Skin Tissue (Child)"):(-766,-202),
46 - _("Custom"):('', '') 46 + _("Custom"):(0, 0)
47 }) 47 })
48 48
49 self.thresh_mri = TwoWaysDictionary({ 49 self.thresh_mri = TwoWaysDictionary({
@@ -61,7 +61,7 @@ class Presets(): @@ -61,7 +61,7 @@ class Presets():
61 _("Fat Tissue (Child)"):(812,952), 61 _("Fat Tissue (Child)"):(812,952),
62 _("Skin Tissue (Adult)"):(306,847), 62 _("Skin Tissue (Adult)"):(306,847),
63 _("Skin Tissue (Child)"):(258,822), 63 _("Skin Tissue (Child)"):(258,822),
64 - _("Custom"):('', '') 64 + _("Custom"):(0, 0)
65 }) 65 })
66 self.__bind_events() 66 self.__bind_events()
67 67
@@ -78,6 +78,7 @@ class Presets(): @@ -78,6 +78,7 @@ class Presets():
78 for key in presets: 78 for key in presets:
79 (t_min, t_max) = presets[key] 79 (t_min, t_max) = presets[key]
80 80
  81 + print(key, t_min, t_max)
81 82
82 if (t_min is None) or (t_max is None): # setting custom preset 83 if (t_min is None) or (t_max is None): # setting custom preset
83 t_min = thresh_min 84 t_min = thresh_min
@@ -181,7 +182,7 @@ def get_wwwl_preset_colours(pfile): @@ -181,7 +182,7 @@ def get_wwwl_preset_colours(pfile):
181 preset = plistlib.readPlist(pfile) 182 preset = plistlib.readPlist(pfile)
182 ncolours = len(preset['Blue']) 183 ncolours = len(preset['Blue'])
183 colours = [] 184 colours = []
184 - for i in xrange(ncolours): 185 + for i in range(ncolours):
185 r = preset['Red'][i] 186 r = preset['Red'][i]
186 g = preset['Green'][i] 187 g = preset['Green'][i]
187 b = preset['Blue'][i] 188 b = preset['Blue'][i]
invesalius/project.py
@@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
17 # detalhes. 17 # detalhes.
18 #-------------------------------------------------------------------------- 18 #--------------------------------------------------------------------------
19 19
  20 +from six import with_metaclass
  21 +
20 import datetime 22 import datetime
21 import glob 23 import glob
22 import os 24 import os
@@ -33,7 +35,7 @@ import vtk @@ -33,7 +35,7 @@ import vtk
33 import invesalius.constants as const 35 import invesalius.constants as const
34 import invesalius.data.polydata_utils as pu 36 import invesalius.data.polydata_utils as pu
35 from invesalius.presets import Presets 37 from invesalius.presets import Presets
36 -from invesalius.utils import Singleton, debug, touch 38 +from invesalius.utils import Singleton, debug, touch, decode
37 import invesalius.version as version 39 import invesalius.version as version
38 40
39 if sys.platform == 'win32': 41 if sys.platform == 'win32':
@@ -45,11 +47,9 @@ if sys.platform == &#39;win32&#39;: @@ -45,11 +47,9 @@ if sys.platform == &#39;win32&#39;:
45 else: 47 else:
46 _has_win32api = False 48 _has_win32api = False
47 49
48 -class Project(object):  
49 - # Only one project will be initialized per time. Therefore, we use  
50 - # Singleton design pattern for implementing it  
51 - __metaclass__= Singleton  
52 - 50 +# Only one project will be initialized per time. Therefore, we use
  51 +# Singleton design pattern for implementing it
  52 +class Project(with_metaclass(Singleton, object)):
53 def __init__(self): 53 def __init__(self):
54 # Patient/ acquistion information 54 # Patient/ acquistion information
55 self.name = '' 55 self.name = ''
@@ -205,7 +205,7 @@ class Project(object): @@ -205,7 +205,7 @@ class Project(object):
205 return measures 205 return measures
206 206
207 def SavePlistProject(self, dir_, filename, compress=False): 207 def SavePlistProject(self, dir_, filename, compress=False):
208 - dir_temp = tempfile.mkdtemp().decode(const.FS_ENCODE) 208 + dir_temp = decode(tempfile.mkdtemp(), const.FS_ENCODE)
209 209
210 self.compress = compress 210 self.compress = compress
211 211
@@ -357,7 +357,7 @@ def Compress(folder, filename, filelist, compress=False): @@ -357,7 +357,7 @@ def Compress(folder, filename, filelist, compress=False):
357 touch(temp_inv3) 357 touch(temp_inv3)
358 temp_inv3 = win32api.GetShortPathName(temp_inv3) 358 temp_inv3 = win32api.GetShortPathName(temp_inv3)
359 359
360 - temp_inv3 = temp_inv3.decode(const.FS_ENCODE) 360 + temp_inv3 = decode(temp_inv3, const.FS_ENCODE)
361 #os.chdir(tmpdir) 361 #os.chdir(tmpdir)
362 #file_list = glob.glob(os.path.join(tmpdir_,"*")) 362 #file_list = glob.glob(os.path.join(tmpdir_,"*"))
363 if compress: 363 if compress:
@@ -374,16 +374,16 @@ def Compress(folder, filename, filelist, compress=False): @@ -374,16 +374,16 @@ def Compress(folder, filename, filelist, compress=False):
374 def Extract(filename, folder): 374 def Extract(filename, folder):
375 if _has_win32api: 375 if _has_win32api:
376 folder = win32api.GetShortPathName(folder) 376 folder = win32api.GetShortPathName(folder)
377 - folder = folder.decode(const.FS_ENCODE) 377 + folder = decode(folder, const.FS_ENCODE)
378 378
379 tar = tarfile.open(filename, "r") 379 tar = tarfile.open(filename, "r")
380 - idir = os.path.split(tar.getnames()[0])[0].decode('utf8') 380 + idir = decode(os.path.split(tar.getnames()[0])[0], 'utf8')
381 os.mkdir(os.path.join(folder, idir)) 381 os.mkdir(os.path.join(folder, idir))
382 filelist = [] 382 filelist = []
383 for t in tar.getmembers(): 383 for t in tar.getmembers():
384 fsrc = tar.extractfile(t) 384 fsrc = tar.extractfile(t)
385 - fname = os.path.join(folder, t.name.decode('utf-8'))  
386 - fdst = file(fname, 'wb') 385 + fname = os.path.join(folder, decode(t.name, 'utf-8'))
  386 + fdst = open(fname, 'wb')
387 shutil.copyfileobj(fsrc, fdst) 387 shutil.copyfileobj(fsrc, fdst)
388 filelist.append(fname) 388 filelist.append(fname)
389 fsrc.close() 389 fsrc.close()
invesalius/reader/bitmap_reader.py
@@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
17 # detalhes. 17 # detalhes.
18 #-------------------------------------------------------------------------- 18 #--------------------------------------------------------------------------
19 import os 19 import os
20 -import Queue  
21 import threading 20 import threading
22 import tempfile 21 import tempfile
23 import sys 22 import sys
@@ -136,7 +135,7 @@ class LoadBitmap: @@ -136,7 +135,7 @@ class LoadBitmap:
136 135
137 def __init__(self, bmp_file, filepath): 136 def __init__(self, bmp_file, filepath):
138 self.bmp_file = bmp_file 137 self.bmp_file = bmp_file
139 - self.filepath = filepath 138 + self.filepath = utils.decode(filepath, const.FS_ENCODE)
140 139
141 self.run() 140 self.run()
142 141
@@ -355,8 +354,10 @@ def ReadBitmap(filepath): @@ -355,8 +354,10 @@ def ReadBitmap(filepath):
355 filepath = win32api.GetShortPathName(filepath) 354 filepath = win32api.GetShortPathName(filepath)
356 355
357 if t == False: 356 if t == False:
358 - measures_info = GetPixelSpacingFromInfoFile(filepath)  
359 - 357 + try:
  358 + measures_info = GetPixelSpacingFromInfoFile(filepath)
  359 + except UnicodeDecodeError:
  360 + measures_info = False
360 if measures_info: 361 if measures_info:
361 Publisher.sendMessage('Set bitmap spacing', measures_info) 362 Publisher.sendMessage('Set bitmap spacing', measures_info)
362 363
@@ -377,6 +378,9 @@ def ReadBitmap(filepath): @@ -377,6 +378,9 @@ def ReadBitmap(filepath):
377 378
378 379
379 def GetPixelSpacingFromInfoFile(filepath): 380 def GetPixelSpacingFromInfoFile(filepath):
  381 + filepath = utils.decode(filepath, const.FS_ENCODE)
  382 + if filepath.endswith('.DS_Store'):
  383 + return False
380 fi = open(filepath, 'r') 384 fi = open(filepath, 'r')
381 lines = fi.readlines() 385 lines = fi.readlines()
382 measure_scale = 'mm' 386 measure_scale = 'mm'
invesalius/reader/dicom.py
@@ -1240,7 +1240,7 @@ class Parser(): @@ -1240,7 +1240,7 @@ class Parser():
1240 encoding = self.GetEncoding() 1240 encoding = self.GetEncoding()
1241 try: 1241 try:
1242 # Returns a unicode decoded in the own dicom encoding 1242 # Returns a unicode decoded in the own dicom encoding
1243 - return name.decode(encoding, 'replace') 1243 + return utils.decode(name, encoding, 'replace')
1244 except(UnicodeEncodeError): 1244 except(UnicodeEncodeError):
1245 return name 1245 return name
1246 1246
@@ -1285,7 +1285,7 @@ class Parser(): @@ -1285,7 +1285,7 @@ class Parser():
1285 1285
1286 try: 1286 try:
1287 # Returns a unicode decoded in the own dicom encoding 1287 # Returns a unicode decoded in the own dicom encoding
1288 - return name.decode(encoding, 'replace') 1288 + return utils.decode(name, encoding, 'replace')
1289 except(UnicodeEncodeError): 1289 except(UnicodeEncodeError):
1290 return name 1290 return name
1291 1291
@@ -1308,7 +1308,7 @@ class Parser(): @@ -1308,7 +1308,7 @@ class Parser():
1308 encoding = self.GetEncoding() 1308 encoding = self.GetEncoding()
1309 # Returns a unicode decoded in the own dicom encoding 1309 # Returns a unicode decoded in the own dicom encoding
1310 try: 1310 try:
1311 - return data.decode(encoding, 'replace') 1311 + return utils.decode(data, encoding, 'replace')
1312 except(UnicodeEncodeError): 1312 except(UnicodeEncodeError):
1313 return data 1313 return data
1314 return "" 1314 return ""
@@ -1526,10 +1526,8 @@ class Parser(): @@ -1526,10 +1526,8 @@ class Parser():
1526 try: 1526 try:
1527 data = self.data_image[str(0x0008)][str(0x1030)] 1527 data = self.data_image[str(0x0008)][str(0x1030)]
1528 if (data): 1528 if (data):
1529 - if isinstance(data, unicode):  
1530 - return data  
1531 encoding = self.GetEncoding() 1529 encoding = self.GetEncoding()
1532 - return data.decode(encoding, 'replace') 1530 + return utils.decode(data, encoding, 'replace')
1533 except(KeyError): 1531 except(KeyError):
1534 return "" 1532 return ""
1535 1533
@@ -1843,31 +1841,31 @@ if __name__ == &quot;__main__&quot;: @@ -1843,31 +1841,31 @@ if __name__ == &quot;__main__&quot;:
1843 fail_count = 0 1841 fail_count = 0
1844 total = 48 1842 total = 48
1845 1843
1846 - for i in xrange(1,total+1): 1844 + for i in range(1,total+1):
1847 filename = "..//data//"+str(i)+".dcm" 1845 filename = "..//data//"+str(i)+".dcm"
1848 1846
1849 parser = Parser() 1847 parser = Parser()
1850 if parser.SetFileName(filename): 1848 if parser.SetFileName(filename):
1851 - print "p:", parser.GetPatientName()  
1852 - print "l:", parser.GetImageLocation()  
1853 - print "o:", parser.GetImagePatientOrientation()  
1854 - print "t:", parser.GetImageThickness()  
1855 - print "s:", parser.GetPixelSpacing()  
1856 - print "x:", parser.GetDimensionX()  
1857 - print "y:", parser.GetDimensionY()  
1858 - print "z:", parser.GetDimensionZ() 1849 + print("p:", parser.GetPatientName())
  1850 + print("l:", parser.GetImageLocation())
  1851 + print("o:", parser.GetImagePatientOrientation())
  1852 + print("t:", parser.GetImageThickness())
  1853 + print("s:", parser.GetPixelSpacing())
  1854 + print("x:", parser.GetDimensionX())
  1855 + print("y:", parser.GetDimensionY())
  1856 + print("z:", parser.GetDimensionZ())
1859 else: 1857 else:
1860 - print "--------------------------------------------------" 1858 + print("--------------------------------------------------")
1861 total-=1 1859 total-=1
1862 fail_count+=1 1860 fail_count+=1
1863 1861
1864 - print "\nREPORT:"  
1865 - print "failed: ", fail_count  
1866 - print "sucess: ", total 1862 + print("\nREPORT:")
  1863 + print("failed: ", fail_count)
  1864 + print("sucess: ", total)
1867 1865
1868 # Example of how to use auxiliary functions 1866 # Example of how to use auxiliary functions
1869 total = 38 1867 total = 38
1870 - for i in xrange(1,total+1): 1868 + for i in range(1,total+1):
1871 if (i==8) or (i==9) or (i==13): 1869 if (i==8) or (i==9) or (i==13):
1872 pass 1870 pass
1873 else: 1871 else:
invesalius/reader/dicom_grouper.py
@@ -124,7 +124,7 @@ class DicomGroup: @@ -124,7 +124,7 @@ class DicomGroup:
124 # (interpolated) 124 # (interpolated)
125 125
126 if _has_win32api: 126 if _has_win32api:
127 - filelist = [win32api.GetShortPathName(dicom.image.file).encode(const.FS_ENCODE) 127 + filelist = [win32api.GetShortPathName(dicom.image.file)
128 for dicom in 128 for dicom in
129 self.slices_dict.values()] 129 self.slices_dict.values()]
130 else: 130 else:
@@ -132,16 +132,19 @@ class DicomGroup: @@ -132,16 +132,19 @@ class DicomGroup:
132 self.slices_dict.values()] 132 self.slices_dict.values()]
133 133
134 # Sort slices using GDCM 134 # Sort slices using GDCM
135 - if (self.dicom.image.orientation_label <> "CORONAL"): 135 + if (self.dicom.image.orientation_label != "CORONAL"):
136 #Organize reversed image 136 #Organize reversed image
137 sorter = gdcm.IPPSorter() 137 sorter = gdcm.IPPSorter()
138 sorter.SetComputeZSpacing(True) 138 sorter.SetComputeZSpacing(True)
139 sorter.SetZSpacingTolerance(1e-10) 139 sorter.SetZSpacingTolerance(1e-10)
140 - sorter.Sort(filelist) 140 + try:
  141 + sorter.Sort([utils.encode(i, const.FS_ENCODE) for i in filelist])
  142 + except TypeError:
  143 + sorter.Sort(filelist)
141 filelist = sorter.GetFilenames() 144 filelist = sorter.GetFilenames()
142 145
143 # for breast-CT of koning manufacturing (KBCT) 146 # for breast-CT of koning manufacturing (KBCT)
144 - if self.slices_dict.values()[0].parser.GetManufacturerName() == "Koning": 147 + if list(self.slices_dict.values())[0].parser.GetManufacturerName() == "Koning":
145 filelist.sort() 148 filelist.sort()
146 149
147 return filelist 150 return filelist
@@ -149,7 +152,7 @@ class DicomGroup: @@ -149,7 +152,7 @@ class DicomGroup:
149 def GetHandSortedList(self): 152 def GetHandSortedList(self):
150 # This will be used to fix problem 1, after merging 153 # This will be used to fix problem 1, after merging
151 # single DicomGroups of same study_id and orientation 154 # single DicomGroups of same study_id and orientation
152 - list_ = self.slices_dict.values() 155 + list_ = list(self.slices_dict.values())
153 dicom = list_[0] 156 dicom = list_[0]
154 axis = ORIENT_MAP[dicom.image.orientation_label] 157 axis = ORIENT_MAP[dicom.image.orientation_label]
155 #list_ = sorted(list_, key = lambda dicom:dicom.image.position[axis]) 158 #list_ = sorted(list_, key = lambda dicom:dicom.image.position[axis])
@@ -173,7 +176,7 @@ class DicomGroup: @@ -173,7 +176,7 @@ class DicomGroup:
173 176
174 def GetDicomSample(self): 177 def GetDicomSample(self):
175 size = len(self.slices_dict) 178 size = len(self.slices_dict)
176 - dicom = self.GetHandSortedList()[size/2] 179 + dicom = self.GetHandSortedList()[size//2]
177 return dicom 180 return dicom
178 181
179 class PatientGroup: 182 class PatientGroup:
@@ -306,7 +309,7 @@ class PatientGroup: @@ -306,7 +309,7 @@ class PatientGroup:
306 309
307 # 3rd STEP: CHECK DIFFERENCES 310 # 3rd STEP: CHECK DIFFERENCES
308 axis = ORIENT_MAP[group_key[0]] # based on orientation 311 axis = ORIENT_MAP[group_key[0]] # based on orientation
309 - for index in xrange(len(sorted_list)-1): 312 + for index in range(len(sorted_list)-1):
310 current = sorted_list[index] 313 current = sorted_list[index]
311 next = sorted_list[index+1] 314 next = sorted_list[index+1]
312 315
invesalius/reader/dicom_reader.py
@@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
17 # detalhes. 17 # detalhes.
18 #-------------------------------------------------------------------------- 18 #--------------------------------------------------------------------------
19 import os 19 import os
20 -import Queue  
21 import threading 20 import threading
22 import tempfile 21 import tempfile
23 import sys 22 import sys
@@ -79,7 +78,7 @@ def SelectLargerDicomGroup(patient_group): @@ -79,7 +78,7 @@ def SelectLargerDicomGroup(patient_group):
79 def SortFiles(filelist, dicom): 78 def SortFiles(filelist, dicom):
80 # Sort slices 79 # Sort slices
81 # FIXME: Coronal Crash. necessary verify 80 # FIXME: Coronal Crash. necessary verify
82 - if (dicom.image.orientation_label <> "CORONAL"): 81 + if (dicom.image.orientation_label != "CORONAL"):
83 ##Organize reversed image 82 ##Organize reversed image
84 sorter = gdcm.IPPSorter() 83 sorter = gdcm.IPPSorter()
85 sorter.SetComputeZSpacing(True) 84 sorter.SetComputeZSpacing(True)
@@ -96,27 +95,29 @@ main_dict = {} @@ -96,27 +95,29 @@ main_dict = {}
96 dict_file = {} 95 dict_file = {}
97 96
98 class LoadDicom: 97 class LoadDicom:
99 -  
100 def __init__(self, grouper, filepath): 98 def __init__(self, grouper, filepath):
101 self.grouper = grouper 99 self.grouper = grouper
102 - self.filepath = filepath  
103 - 100 + self.filepath = utils.decode(filepath, const.FS_ENCODE)
104 self.run() 101 self.run()
105 - 102 +
106 def run(self): 103 def run(self):
107 grouper = self.grouper 104 grouper = self.grouper
108 reader = gdcm.ImageReader() 105 reader = gdcm.ImageReader()
109 if _has_win32api: 106 if _has_win32api:
110 - reader.SetFileName(win32api.GetShortPathName(self.filepath).encode(const.FS_ENCODE)) 107 + try:
  108 + reader.SetFileName(utils.encode(win32api.GetShortPathName(self.filepath),
  109 + const.FS_ENCODE))
  110 + except TypeError:
  111 + reader.SetFileName(win32api.GetShortPathName(self.filepath))
111 else: 112 else:
112 - reader.SetFileName(self.filepath)  
113 - 113 + try:
  114 + reader.SetFileName(utils.encode(self.filepath, const.FS_ENCODE))
  115 + except TypeError:
  116 + reader.SetFileName(self.filepath)
114 if (reader.Read()): 117 if (reader.Read()):
115 file = reader.GetFile() 118 file = reader.GetFile()
116 -  
117 # Retrieve data set 119 # Retrieve data set
118 dataSet = file.GetDataSet() 120 dataSet = file.GetDataSet()
119 -  
120 # Retrieve header 121 # Retrieve header
121 header = file.GetHeader() 122 header = file.GetHeader()
122 stf = gdcm.StringFilter() 123 stf = gdcm.StringFilter()
@@ -158,7 +159,7 @@ class LoadDicom: @@ -158,7 +159,7 @@ class LoadDicom:
158 data_dict[group] = {} 159 data_dict[group] = {}
159 160
160 if not(utils.VerifyInvalidPListCharacter(data[1])): 161 if not(utils.VerifyInvalidPListCharacter(data[1])):
161 - data_dict[group][field] = data[1].decode(encoding) 162 + data_dict[group][field] = utils.decode(data[1], encoding)
162 else: 163 else:
163 data_dict[group][field] = "Invalid Character" 164 data_dict[group][field] = "Invalid Character"
164 165
@@ -183,7 +184,7 @@ class LoadDicom: @@ -183,7 +184,7 @@ class LoadDicom:
183 data_dict[group] = {} 184 data_dict[group] = {}
184 185
185 if not(utils.VerifyInvalidPListCharacter(data[1])): 186 if not(utils.VerifyInvalidPListCharacter(data[1])):
186 - data_dict[group][field] = data[1].decode(encoding, 'replace') 187 + data_dict[group][field] = utils.decode(data[1], encoding, 'replace')
187 else: 188 else:
188 data_dict[group][field] = "Invalid Character" 189 data_dict[group][field] = "Invalid Character"
189 190
@@ -201,7 +202,7 @@ class LoadDicom: @@ -201,7 +202,7 @@ class LoadDicom:
201 window = None 202 window = None
202 203
203 if _has_win32api: 204 if _has_win32api:
204 - thumbnail_path = imagedata_utils.create_dicom_thumbnails(win32api.GetShortPathName(self.filepath).encode(const.FS_ENCODE), window, level) 205 + thumbnail_path = imagedata_utils.create_dicom_thumbnails(win32api.GetShortPathName(self.filepath), window, level)
205 else: 206 else:
206 thumbnail_path = imagedata_utils.create_dicom_thumbnails(self.filepath, window, level) 207 thumbnail_path = imagedata_utils.create_dicom_thumbnails(self.filepath, window, level)
207 208
@@ -211,10 +212,10 @@ class LoadDicom: @@ -211,10 +212,10 @@ class LoadDicom:
211 direc_cosines = img.GetDirectionCosines() 212 direc_cosines = img.GetDirectionCosines()
212 orientation = gdcm.Orientation() 213 orientation = gdcm.Orientation()
213 try: 214 try:
214 - type = orientation.GetType(tuple(direc_cosines)) 215 + _type = orientation.GetType(tuple(direc_cosines))
215 except TypeError: 216 except TypeError:
216 - type = orientation.GetType(direc_cosines)  
217 - label = orientation.GetLabel(type) 217 + _type = orientation.GetType(direc_cosines)
  218 + label = orientation.GetLabel(_type)
218 219
219 220
220 # ---------- Refactory -------------------------------------- 221 # ---------- Refactory --------------------------------------
@@ -305,7 +306,7 @@ def yGetDicomGroups(directory, recursive=True, gui=True): @@ -305,7 +306,7 @@ def yGetDicomGroups(directory, recursive=True, gui=True):
305 306
306 307
307 def GetDicomGroups(directory, recursive=True): 308 def GetDicomGroups(directory, recursive=True):
308 - return yGetDicomGroups(directory, recursive, gui=False).next() 309 + return next(yGetDicomGroups(directory, recursive, gui=False))
309 310
310 311
311 class ProgressDicomReader: 312 class ProgressDicomReader:
@@ -333,7 +334,7 @@ class ProgressDicomReader: @@ -333,7 +334,7 @@ class ProgressDicomReader:
333 def GetDicomGroups(self, path, recursive): 334 def GetDicomGroups(self, path, recursive):
334 335
335 if not const.VTK_WARNING: 336 if not const.VTK_WARNING:
336 - log_path = os.path.join(const.USER_LOG_DIR, 'vtkoutput.txt').encode(const.FS_ENCODE) 337 + log_path = utils.encode(os.path.join(const.USER_LOG_DIR, 'vtkoutput.txt'), const.FS_ENCODE)
337 fow = vtk.vtkFileOutputWindow() 338 fow = vtk.vtkFileOutputWindow()
338 fow.SetFileName(log_path) 339 fow.SetFileName(log_path)
339 ow = vtk.vtkOutputWindow() 340 ow = vtk.vtkOutputWindow()
@@ -341,7 +342,7 @@ class ProgressDicomReader: @@ -341,7 +342,7 @@ class ProgressDicomReader:
341 342
342 y = yGetDicomGroups(path, recursive) 343 y = yGetDicomGroups(path, recursive)
343 for value_progress in y: 344 for value_progress in y:
344 - print ">>>>", value_progress 345 + print(">>>>", value_progress)
345 if not self.running: 346 if not self.running:
346 break 347 break
347 if isinstance(value_progress, tuple): 348 if isinstance(value_progress, tuple):
invesalius/session.py
@@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
17 # detalhes. 17 # detalhes.
18 #-------------------------------------------------------------------------- 18 #--------------------------------------------------------------------------
19 19
  20 +from six import with_metaclass
  21 +
20 try: 22 try:
21 import configparser as ConfigParser 23 import configparser as ConfigParser
22 except(ImportError): 24 except(ImportError):
@@ -33,7 +35,7 @@ import codecs @@ -33,7 +35,7 @@ import codecs
33 from wx.lib.pubsub import pub as Publisher 35 from wx.lib.pubsub import pub as Publisher
34 import wx 36 import wx
35 37
36 -from invesalius.utils import Singleton, debug 38 +from invesalius.utils import Singleton, debug, decode
37 from random import randint 39 from random import randint
38 40
39 FS_ENCODE = sys.getfilesystemencoding() 41 FS_ENCODE = sys.getfilesystemencoding()
@@ -43,9 +45,9 @@ if sys.platform == &#39;win32&#39;: @@ -43,9 +45,9 @@ if sys.platform == &#39;win32&#39;:
43 try: 45 try:
44 USER_DIR = expand_user() 46 USER_DIR = expand_user()
45 except: 47 except:
46 - USER_DIR = os.path.expanduser('~').decode(FS_ENCODE) 48 + USER_DIR = decode(os.path.expanduser('~'), FS_ENCODE)
47 else: 49 else:
48 - USER_DIR = os.path.expanduser('~').decode(FS_ENCODE) 50 + USER_DIR = decode(os.path.expanduser('~'), FS_ENCODE)
49 51
50 USER_INV_DIR = os.path.join(USER_DIR, u'.invesalius') 52 USER_INV_DIR = os.path.join(USER_DIR, u'.invesalius')
51 USER_PRESET_DIR = os.path.join(USER_INV_DIR, u'presets') 53 USER_PRESET_DIR = os.path.join(USER_INV_DIR, u'presets')
@@ -55,10 +57,9 @@ USER_INV_CFG_PATH = os.path.join(USER_INV_DIR, &#39;config.cfg&#39;) @@ -55,10 +57,9 @@ USER_INV_CFG_PATH = os.path.join(USER_INV_DIR, &#39;config.cfg&#39;)
55 SESSION_ENCODING = 'utf8' 57 SESSION_ENCODING = 'utf8'
56 58
57 59
58 -class Session(object):  
59 - # Only one session will be initialized per time. Therefore, we use  
60 - # Singleton design pattern for implementing it  
61 - __metaclass__= Singleton 60 +# Only one session will be initialized per time. Therefore, we use
  61 +# Singleton design pattern for implementing it
  62 +class Session(with_metaclass(Singleton, object)):
62 63
63 def __init__(self): 64 def __init__(self):
64 self.temp_item = False 65 self.temp_item = False
@@ -221,7 +222,7 @@ class Session(object): @@ -221,7 +222,7 @@ class Session(object):
221 222
222 # Remove oldest projects from list 223 # Remove oldest projects from list
223 if len(l)>const.PROJ_MAX: 224 if len(l)>const.PROJ_MAX:
224 - for i in xrange(len(l)-const.PROJ_MAX): 225 + for i in range(len(l)-const.PROJ_MAX):
225 l.pop() 226 l.pop()
226 227
227 def GetLanguage(self): 228 def GetLanguage(self):
invesalius/style.py
@@ -64,7 +64,7 @@ from wx.lib.pubsub import pub as Publisher @@ -64,7 +64,7 @@ from wx.lib.pubsub import pub as Publisher
64 #---------------------- 64 #----------------------
65 65
66 66
67 -import constants as const 67 +import invesalius.constants as const
68 68
69 class StyleStateManager(object): 69 class StyleStateManager(object):
70 # don't need to be singleton, only needs to be instantiated inside 70 # don't need to be singleton, only needs to be instantiated inside
invesalius/utils.py
@@ -239,13 +239,13 @@ def calculate_resizing_tofitmemory(x_size,y_size,n_slices,byte): @@ -239,13 +239,13 @@ def calculate_resizing_tofitmemory(x_size,y_size,n_slices,byte):
239 ram_total = psutil.phymem_usage().total 239 ram_total = psutil.phymem_usage().total
240 swap_free = psutil.virtmem_usage().free 240 swap_free = psutil.virtmem_usage().free
241 except: 241 except:
242 - print "Exception! psutil version < 0.3 (not recommended)" 242 + print("Exception! psutil version < 0.3 (not recommended)")
243 ram_total = psutil.TOTAL_PHYMEM # this is for psutil < 0.3 243 ram_total = psutil.TOTAL_PHYMEM # this is for psutil < 0.3
244 ram_free = 0.8 * psutil.TOTAL_PHYMEM 244 ram_free = 0.8 * psutil.TOTAL_PHYMEM
245 swap_free = psutil.avail_virtmem() 245 swap_free = psutil.avail_virtmem()
246 246
247 - print "RAM_FREE=", ram_free  
248 - print "RAM_TOTAL=", ram_total 247 + print("RAM_FREE=", ram_free)
  248 + print( "RAM_TOTAL=", ram_total)
249 249
250 if (sys.platform == 'win32'): 250 if (sys.platform == 'win32'):
251 if (platform.architecture()[0] == '32bit'): 251 if (platform.architecture()[0] == '32bit'):
@@ -371,8 +371,14 @@ def get_system_encoding(): @@ -371,8 +371,14 @@ def get_system_encoding():
371 371
372 372
373 def UpdateCheck(): 373 def UpdateCheck():
374 - import urllib  
375 - import urllib2 374 + try:
  375 + from urllib.parse import urlencode
  376 + from urllib.request import urlopen, Request
  377 + from urllib.error import HTTPError
  378 + except ImportError:
  379 + from urllib import urlencode
  380 + from urllib2 import urlopen, Request, HTTPError
  381 +
376 import wx 382 import wx
377 import invesalius.session as ses 383 import invesalius.session as ses
378 def _show_update_info(): 384 def _show_update_info():
@@ -385,7 +391,7 @@ def UpdateCheck(): @@ -385,7 +391,7 @@ def UpdateCheck():
385 msgdlg.Show() 391 msgdlg.Show()
386 #msgdlg.Destroy() 392 #msgdlg.Destroy()
387 393
388 - print "Checking updates..." 394 + print("Checking updates...")
389 395
390 # Check if there is a language set 396 # Check if there is a language set
391 #import invesalius.i18n as i18n import invesalius.session as ses 397 #import invesalius.i18n as i18n import invesalius.session as ses
@@ -411,14 +417,14 @@ def UpdateCheck(): @@ -411,14 +417,14 @@ def UpdateCheck():
411 'architecture' : platform.architecture()[0], 417 'architecture' : platform.architecture()[0],
412 'language' : lang, 418 'language' : lang,
413 'random_id' : random_id } 419 'random_id' : random_id }
414 - data = urllib.urlencode(data)  
415 - req = urllib2.Request(url, data, headers) 420 + data = urlencode(data).encode('utf8')
  421 + req = Request(url, data, headers)
416 try: 422 try:
417 - response = urllib2.urlopen(req, timeout=10) 423 + response = urlopen(req, timeout=10)
418 except: 424 except:
419 return 425 return
420 - last = response.readline().rstrip()  
421 - url = response.readline().rstrip() 426 + last = response.readline().rstrip().decode('utf8')
  427 + url = response.readline().rstrip().decode('utf8')
422 428
423 try: 429 try:
424 last_ver = LooseVersion(last) 430 last_ver = LooseVersion(last)
@@ -427,14 +433,14 @@ def UpdateCheck(): @@ -427,14 +433,14 @@ def UpdateCheck():
427 return 433 return
428 434
429 if last_ver > actual_ver: 435 if last_ver > actual_ver:
430 - print " ...New update found!!! -> version:", last #, ", url=",url 436 + print(" ...New update found!!! -> version:", last) #, ", url=",url
431 wx.CallAfter(wx.CallLater, 1000, _show_update_info) 437 wx.CallAfter(wx.CallLater, 1000, _show_update_info)
432 438
433 439
434 def vtkarray_to_numpy(m): 440 def vtkarray_to_numpy(m):
435 nm = np.zeros((4, 4)) 441 nm = np.zeros((4, 4))
436 - for i in xrange(4):  
437 - for j in xrange(4): 442 + for i in range(4):
  443 + for j in range(4):
438 nm[i, j] = m.GetElement(i, j) 444 nm[i, j] = m.GetElement(i, j)
439 return nm 445 return nm
440 446
@@ -442,3 +448,17 @@ def vtkarray_to_numpy(m): @@ -442,3 +448,17 @@ def vtkarray_to_numpy(m):
442 def touch(fname): 448 def touch(fname):
443 with open(fname, 'a'): 449 with open(fname, 'a'):
444 pass 450 pass
  451 +
  452 +
  453 +def decode(text, encoding, *args):
  454 + try:
  455 + return text.decode(encoding, *args)
  456 + except AttributeError:
  457 + return text
  458 +
  459 +
  460 +def encode(text, encoding, *args):
  461 + try:
  462 + return text.encode(encoding, *args)
  463 + except AttributeError:
  464 + return text
445 \ No newline at end of file 465 \ No newline at end of file