Commit ef52a4957efdae9fe63f840cb0d5179456c937e7

Authored by Paulo Henrique Junqueira Amorim
1 parent 4ed0515b

FIX: Error save preset name in win64

Showing 1 changed file with 26 additions and 22 deletions   Show diff stats
invesalius/gui/dialogs.py
@@ -31,7 +31,7 @@ import project @@ -31,7 +31,7 @@ import project
31 class NumberDialog(wx.Dialog): 31 class NumberDialog(wx.Dialog):
32 def __init__(self, message, value=0): 32 def __init__(self, message, value=0):
33 pre = wx.PreDialog() 33 pre = wx.PreDialog()
34 - pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize, pos=wx.DefaultPosition, 34 + pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize, pos=wx.DefaultPosition,
35 style=wx.DEFAULT_DIALOG_STYLE) 35 style=wx.DEFAULT_DIALOG_STYLE)
36 self.PostCreate(pre) 36 self.PostCreate(pre)
37 37
@@ -46,7 +46,7 @@ class NumberDialog(wx.Dialog): @@ -46,7 +46,7 @@ class NumberDialog(wx.Dialog):
46 signedForegroundColour = "Black") 46 signedForegroundColour = "Black")
47 self.num_ctrl = num_ctrl 47 self.num_ctrl = num_ctrl
48 48
49 - # Buttons 49 + # Buttons
50 btn_ok = wx.Button(self, wx.ID_OK) 50 btn_ok = wx.Button(self, wx.ID_OK)
51 btn_ok.SetHelpText(_("Value will be applied.")) 51 btn_ok.SetHelpText(_("Value will be applied."))
52 btn_ok.SetDefault() 52 btn_ok.SetDefault()
@@ -57,7 +57,7 @@ class NumberDialog(wx.Dialog): @@ -57,7 +57,7 @@ class NumberDialog(wx.Dialog):
57 btnsizer = wx.StdDialogButtonSizer() 57 btnsizer = wx.StdDialogButtonSizer()
58 btnsizer.AddButton(btn_ok) 58 btnsizer.AddButton(btn_ok)
59 btnsizer.AddButton(btn_cancel) 59 btnsizer.AddButton(btn_cancel)
60 - btnsizer.Realize() 60 + btnsizer.Realize()
61 61
62 62
63 sizer = wx.BoxSizer(wx.VERTICAL) 63 sizer = wx.BoxSizer(wx.VERTICAL)
@@ -104,15 +104,15 @@ class ProgressDialog(object): @@ -104,15 +104,15 @@ class ProgressDialog(object):
104 #| wx.PD_ESTIMATED_TIME 104 #| wx.PD_ESTIMATED_TIME
105 #| wx.PD_REMAINING_TIME 105 #| wx.PD_REMAINING_TIME
106 ) 106 )
107 - 107 +
108 self.dlg.Bind(wx.EVT_BUTTON, self.Cancel) 108 self.dlg.Bind(wx.EVT_BUTTON, self.Cancel)
109 self.dlg.SetSize(wx.Size(250,150)) 109 self.dlg.SetSize(wx.Size(250,150))
110 - 110 +
111 def Cancel(self, evt): 111 def Cancel(self, evt):
112 ps.Publisher().sendMessage("Cancel DICOM load") 112 ps.Publisher().sendMessage("Cancel DICOM load")
113 - 113 +
114 def Update(self, value, message): 114 def Update(self, value, message):
115 - if(int(value) != self.maximum): 115 + if(int(value) != self.maximum):
116 try: 116 try:
117 self.dlg.Update(value,message) 117 self.dlg.Update(value,message)
118 #TODO: 118 #TODO:
@@ -122,7 +122,7 @@ class ProgressDialog(object): @@ -122,7 +122,7 @@ class ProgressDialog(object):
122 return True 122 return True
123 else: 123 else:
124 return False 124 return False
125 - 125 +
126 def Close(self): 126 def Close(self):
127 self.dlg.Destroy() 127 self.dlg.Destroy()
128 128
@@ -184,7 +184,7 @@ def ShowImportDirDialog(): @@ -184,7 +184,7 @@ def ShowImportDirDialog():
184 return path 184 return path
185 185
186 def ShowSaveAsProjectDialog(default_filename=None): 186 def ShowSaveAsProjectDialog(default_filename=None):
187 - current_dir = os.path.abspath(".") 187 + current_dir = os.path.abspath(".")
188 dlg = wx.FileDialog(None, 188 dlg = wx.FileDialog(None,
189 _("Save project as..."), # title 189 _("Save project as..."), # title
190 "", # last used directory 190 "", # last used directory
@@ -193,14 +193,14 @@ def ShowSaveAsProjectDialog(default_filename=None): @@ -193,14 +193,14 @@ def ShowSaveAsProjectDialog(default_filename=None):
193 wx.SAVE|wx.OVERWRITE_PROMPT) 193 wx.SAVE|wx.OVERWRITE_PROMPT)
194 #dlg.SetFilterIndex(0) # default is VTI 194 #dlg.SetFilterIndex(0) # default is VTI
195 195
196 - filename = None 196 + filename = None
197 if dlg.ShowModal() == wx.ID_OK: 197 if dlg.ShowModal() == wx.ID_OK:
198 filename = dlg.GetPath() 198 filename = dlg.GetPath()
199 extension = "inv3" 199 extension = "inv3"
200 if sys.platform != 'win32': 200 if sys.platform != 'win32':
201 if filename.split(".")[-1] != extension: 201 if filename.split(".")[-1] != extension:
202 filename = filename + "." + extension 202 filename = filename + "." + extension
203 - 203 +
204 os.chdir(current_dir) 204 os.chdir(current_dir)
205 return filename 205 return filename
206 206
@@ -217,14 +217,14 @@ def ShowSaveAsProjectDialog(default_filename=None): @@ -217,14 +217,14 @@ def ShowSaveAsProjectDialog(default_filename=None):
217 class MessageDialog(wx.Dialog): 217 class MessageDialog(wx.Dialog):
218 def __init__(self, message): 218 def __init__(self, message):
219 pre = wx.PreDialog() 219 pre = wx.PreDialog()
220 - pre.Create(None, -1, "InVesalius 3", size=(360, 370), pos=wx.DefaultPosition, 220 + pre.Create(None, -1, "InVesalius 3", size=(360, 370), pos=wx.DefaultPosition,
221 style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION) 221 style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)
222 self.PostCreate(pre) 222 self.PostCreate(pre)
223 223
224 # Static text which contains message to user 224 # Static text which contains message to user
225 label = wx.StaticText(self, -1, message) 225 label = wx.StaticText(self, -1, message)
226 226
227 - # Buttons 227 + # Buttons
228 btn_yes = wx.Button(self, wx.ID_YES) 228 btn_yes = wx.Button(self, wx.ID_YES)
229 btn_yes.SetHelpText("") 229 btn_yes.SetHelpText("")
230 btn_yes.SetDefault() 230 btn_yes.SetDefault()
@@ -239,7 +239,7 @@ class MessageDialog(wx.Dialog): @@ -239,7 +239,7 @@ class MessageDialog(wx.Dialog):
239 btnsizer.AddButton(btn_yes) 239 btnsizer.AddButton(btn_yes)
240 btnsizer.AddButton(btn_cancel) 240 btnsizer.AddButton(btn_cancel)
241 btnsizer.AddButton(btn_no) 241 btnsizer.AddButton(btn_no)
242 - btnsizer.Realize() 242 + btnsizer.Realize()
243 243
244 244
245 sizer = wx.BoxSizer(wx.VERTICAL) 245 sizer = wx.BoxSizer(wx.VERTICAL)
@@ -263,7 +263,7 @@ def SaveChangesDialog__Old(filename): @@ -263,7 +263,7 @@ def SaveChangesDialog__Old(filename):
263 return 0 263 return 0
264 else: 264 else:
265 return -1 265 return -1
266 - 266 +
267 267
268 def ImportEmptyDirectory(dirpath): 268 def ImportEmptyDirectory(dirpath):
269 msg = "%s is an empty directory." % dirpath 269 msg = "%s is an empty directory." % dirpath
@@ -274,7 +274,7 @@ def ImportEmptyDirectory(dirpath): @@ -274,7 +274,7 @@ def ImportEmptyDirectory(dirpath):
274 else: 274 else:
275 dlg = wx.MessageDialog(None, msg, 275 dlg = wx.MessageDialog(None, msg,
276 "InVesalius 3", 276 "InVesalius 3",
277 - wx.ICON_INFORMATION | wx.OK) 277 + wx.ICON_INFORMATION | wx.OK)
278 dlg.ShowModal() 278 dlg.ShowModal()
279 dlg.Destroy() 279 dlg.Destroy()
280 280
@@ -285,9 +285,9 @@ def ImportInvalidFiles(): @@ -285,9 +285,9 @@ def ImportInvalidFiles():
285 wx.ICON_INFORMATION | wx.OK) 285 wx.ICON_INFORMATION | wx.OK)
286 else: 286 else:
287 dlg = wx.MessageDialog(None, msg, "InVesalius 3", 287 dlg = wx.MessageDialog(None, msg, "InVesalius 3",
288 - wx.ICON_INFORMATION | wx.OK) 288 + wx.ICON_INFORMATION | wx.OK)
289 dlg.ShowModal() 289 dlg.ShowModal()
290 - dlg.Destroy() 290 + dlg.Destroy()
291 291
292 def SaveChangesDialog(filename): 292 def SaveChangesDialog(filename):
293 current_dir = os.path.abspath(".") 293 current_dir = os.path.abspath(".")
@@ -303,7 +303,7 @@ def SaveChangesDialog(filename): @@ -303,7 +303,7 @@ def SaveChangesDialog(filename):
303 answer = dlg.ShowModal() 303 answer = dlg.ShowModal()
304 dlg.Destroy() 304 dlg.Destroy()
305 os.chdir(current_dir) 305 os.chdir(current_dir)
306 - 306 +
307 if answer == wx.ID_YES: 307 if answer == wx.ID_YES:
308 return 1 308 return 1
309 elif answer == wx.ID_NO: 309 elif answer == wx.ID_NO:
@@ -333,7 +333,7 @@ def SaveChangesDialog2(filename): @@ -333,7 +333,7 @@ def SaveChangesDialog2(filename):
333 333
334 334
335 def ShowAboutDialog(parent): 335 def ShowAboutDialog(parent):
336 - 336 +
337 info = wx.AboutDialogInfo() 337 info = wx.AboutDialogInfo()
338 info.Name = "InVesalius" 338 info.Name = "InVesalius"
339 info.Version = "3.a.1 - RP" 339 info.Version = "3.a.1 - RP"
@@ -364,7 +364,11 @@ def ShowSavePresetDialog(default_filename="raycasting"): @@ -364,7 +364,11 @@ def ShowSavePresetDialog(default_filename="raycasting"):
364 _("Save raycasting preset as:"), 364 _("Save raycasting preset as:"),
365 "InVesalius 3") 365 "InVesalius 3")
366 #dlg.SetFilterIndex(0) # default is VTI 366 #dlg.SetFilterIndex(0) # default is VTI
367 - filename = None  
368 - if dlg.ShowModal() == wx.ID_OK: 367 + filename = None
  368 + try:
  369 + if dlg.ShowModal() == wx.ID_OK:
  370 + filename = dlg.GetValue()
  371 + except(wx._core.PyAssertionErro):
369 filename = dlg.GetValue() 372 filename = dlg.GetValue()
  373 +
370 return filename 374 return filename