Commit 262a7d34fa59387876e233fc339bbd4c079fcfe7

Authored by Paulo Henrique Junqueira Amorim
1 parent fbdeac95

FIX: Last folder is not being saved when click cancel in the import dialog #171

Showing 1 changed file with 14 additions and 12 deletions   Show diff stats
invesalius/gui/dialogs.py
@@ -98,7 +98,7 @@ class ProgressDialog(object): @@ -98,7 +98,7 @@ class ProgressDialog(object):
98 self.style = wx.PD_APP_MODAL 98 self.style = wx.PD_APP_MODAL
99 if abort: 99 if abort:
100 self.style = wx.PD_APP_MODAL | wx.PD_CAN_ABORT 100 self.style = wx.PD_APP_MODAL | wx.PD_CAN_ABORT
101 - 101 +
102 self.dlg = wx.ProgressDialog(self.title, 102 self.dlg = wx.ProgressDialog(self.title,
103 self.msg, 103 self.msg,
104 maximum = self.maximum, 104 maximum = self.maximum,
@@ -183,11 +183,13 @@ def ShowImportDirDialog(): @@ -183,11 +183,13 @@ def ShowImportDirDialog():
183 else: 183 else:
184 path = dlg.GetPath().encode('utf-8') 184 path = dlg.GetPath().encode('utf-8')
185 185
186 - if (sys.platform != 'darwin'):  
187 - session.SetLastDicomFolder(path)  
188 -  
189 except(wx._core.PyAssertionError): #TODO: error win64 186 except(wx._core.PyAssertionError): #TODO: error win64
190 - path = dlg.GetPath() 187 + if (dlg.GetPath()):
  188 + path = dlg.GetPath()
  189 +
  190 + if (sys.platform != 'darwin'):
  191 + if (path):
  192 + session.SetLastDicomFolder(path)
191 193
192 # Only destroy a dialog after you're done with it. 194 # Only destroy a dialog after you're done with it.
193 dlg.Destroy() 195 dlg.Destroy()
@@ -423,7 +425,7 @@ class NewSurfaceDialog(wx.Dialog): @@ -423,7 +425,7 @@ class NewSurfaceDialog(wx.Dialog):
423 self.CenterOnScreen() 425 self.CenterOnScreen()
424 426
425 # LINE 1: Surface name 427 # LINE 1: Surface name
426 - 428 +
427 label_surface = wx.StaticText(self, -1, _("New surface name:")) 429 label_surface = wx.StaticText(self, -1, _("New surface name:"))
428 430
429 default_name = const.SURFACE_NAME_PATTERN %(surface.Surface.general_index+2) 431 default_name = const.SURFACE_NAME_PATTERN %(surface.Surface.general_index+2)
@@ -442,7 +444,7 @@ class NewSurfaceDialog(wx.Dialog): @@ -442,7 +444,7 @@ class NewSurfaceDialog(wx.Dialog):
442 index_list = project.mask_dict.keys() 444 index_list = project.mask_dict.keys()
443 index_list.sort() 445 index_list.sort()
444 self.mask_list = [project.mask_dict[index].name for index in index_list] 446 self.mask_list = [project.mask_dict[index].name for index in index_list]
445 - 447 +
446 448
447 # Mask selection combo 449 # Mask selection combo
448 combo_mask = wx.ComboBox(self, -1, "", choices= self.mask_list, 450 combo_mask = wx.ComboBox(self, -1, "", choices= self.mask_list,
@@ -490,7 +492,7 @@ class NewSurfaceDialog(wx.Dialog): @@ -490,7 +492,7 @@ class NewSurfaceDialog(wx.Dialog):
490 btn_ok = wx.Button(self, wx.ID_OK) 492 btn_ok = wx.Button(self, wx.ID_OK)
491 btn_ok.SetDefault() 493 btn_ok.SetDefault()
492 btn_cancel = wx.Button(self, wx.ID_CANCEL) 494 btn_cancel = wx.Button(self, wx.ID_CANCEL)
493 - 495 +
494 btnsizer = wx.StdDialogButtonSizer() 496 btnsizer = wx.StdDialogButtonSizer()
495 btnsizer.AddButton(btn_ok) 497 btnsizer.AddButton(btn_ok)
496 btnsizer.AddButton(btn_cancel) 498 btnsizer.AddButton(btn_cancel)
@@ -509,10 +511,10 @@ class NewSurfaceDialog(wx.Dialog): @@ -509,10 +511,10 @@ class NewSurfaceDialog(wx.Dialog):
509 511
510 def GetValue(self): 512 def GetValue(self):
511 mask_index = self.combo_mask.GetSelection() 513 mask_index = self.combo_mask.GetSelection()
512 - surface_name = self.text.GetValue() 514 + surface_name = self.text.GetValue()
513 quality = const.SURFACE_QUALITY_LIST[self.combo_quality.GetSelection()] 515 quality = const.SURFACE_QUALITY_LIST[self.combo_quality.GetSelection()]
514 fill_holes = self.check_box_holes.GetValue() 516 fill_holes = self.check_box_holes.GetValue()
515 - keep_largest = self.check_box_largest.GetValue() 517 + keep_largest = self.check_box_largest.GetValue()
516 return (mask_index, surface_name, quality, fill_holes, keep_largest) 518 return (mask_index, surface_name, quality, fill_holes, keep_largest)
517 519
518 INDEX_TO_EXTENSION = {0: "bmp", 1: "jpg", 2: "png", 3: "ps", 4:"povray", 5:"tiff"} 520 INDEX_TO_EXTENSION = {0: "bmp", 1: "jpg", 2: "png", 3: "ps", 4:"povray", 5:"tiff"}
@@ -526,7 +528,7 @@ WILDCARD_SAVE_PICTURE = _("BMP image")+" (*.bmp)|*.bmp|"+\ @@ -526,7 +528,7 @@ WILDCARD_SAVE_PICTURE = _("BMP image")+" (*.bmp)|*.bmp|"+\
526 528
527 def ExportPicture(type_=""): 529 def ExportPicture(type_=""):
528 import constants as const 530 import constants as const
529 - 531 +
530 INDEX_TO_TYPE = {0: const.FILETYPE_BMP, 532 INDEX_TO_TYPE = {0: const.FILETYPE_BMP,
531 1: const.FILETYPE_JPG, 533 1: const.FILETYPE_JPG,
532 2: const.FILETYPE_PNG, 534 2: const.FILETYPE_PNG,
@@ -548,7 +550,7 @@ def ExportPicture(type_=""): @@ -548,7 +550,7 @@ def ExportPicture(type_=""):
548 WILDCARD_SAVE_PICTURE, 550 WILDCARD_SAVE_PICTURE,
549 wx.SAVE|wx.OVERWRITE_PROMPT) 551 wx.SAVE|wx.OVERWRITE_PROMPT)
550 dlg.SetFilterIndex(1) # default is VTI 552 dlg.SetFilterIndex(1) # default is VTI
551 - 553 +
552 if dlg.ShowModal() == wx.ID_OK: 554 if dlg.ShowModal() == wx.ID_OK:
553 filetype_index = dlg.GetFilterIndex() 555 filetype_index = dlg.GetFilterIndex()
554 filetype = INDEX_TO_TYPE[filetype_index] 556 filetype = INDEX_TO_TYPE[filetype_index]