Commit 0d35b56018f88c0ffca3a7b82da18e51f6ab62c1

Authored by tatiana
1 parent cb15af65

FIX: Import empty directory (#81)

invesalius/control.py
@@ -106,7 +106,11 @@ class Controller(): @@ -106,7 +106,11 @@ class Controller():
106 106
107 # Import project 107 # Import project
108 dirpath = dialog.ShowImportDirDialog() 108 dirpath = dialog.ShowImportDirDialog()
109 - if dirpath: 109 + ###
  110 + print dirpath
  111 + if dirpath and not os.listdir(dirpath):
  112 + dialog.ImportEmptyDirectory(dirpath)
  113 + elif dirpath:
110 self.StartImportPanel(dirpath) 114 self.StartImportPanel(dirpath)
111 ps.Publisher().sendMessage("Load data to import panel", dirpath) 115 ps.Publisher().sendMessage("Load data to import panel", dirpath)
112 116
invesalius/gui/dialogs.py
@@ -249,7 +249,7 @@ class MessageDialog(wx.Dialog): @@ -249,7 +249,7 @@ class MessageDialog(wx.Dialog):
249 self.Centre() 249 self.Centre()
250 250
251 def SaveChangesDialog__Old(filename): 251 def SaveChangesDialog__Old(filename):
252 - message = "Save changes to "+filename+"?" 252 + message = "Save changes to %s?"%filename
253 dlg = MessageDialog(message) 253 dlg = MessageDialog(message)
254 254
255 answer = dlg.ShowModal() 255 answer = dlg.ShowModal()
@@ -262,14 +262,28 @@ def SaveChangesDialog__Old(filename): @@ -262,14 +262,28 @@ def SaveChangesDialog__Old(filename):
262 return -1 262 return -1
263 263
264 264
  265 +def ImportEmptyDirectory(dirpath):
  266 + if sys.platform == 'darwin':
  267 + dlg = wx.MessageDialog(None, "",
  268 + "%s is an empty directory." % dirpath,
  269 + wx.ICON_INFORMATION | wx.OK)
  270 + else:
  271 + dlg = wx.MessageDialog(None, "%s is an empty directory." % dirpath,
  272 + "InVesalius 3",
  273 + wx.ICON_INFORMATION | wx.OK)
  274 + dlg.ShowModal()
  275 + dlg.Destroy()
  276 +
  277 +
  278 +
265 def SaveChangesDialog(filename): 279 def SaveChangesDialog(filename):
266 current_dir = os.path.abspath(".") 280 current_dir = os.path.abspath(".")
267 if sys.platform == 'darwin': 281 if sys.platform == 'darwin':
268 dlg = wx.MessageDialog(None, "", 282 dlg = wx.MessageDialog(None, "",
269 - "Save changes to "+filename+"?", 283 + "Save changes to %s?"%filename,
270 wx.ICON_QUESTION | wx.YES_NO | wx.CANCEL) 284 wx.ICON_QUESTION | wx.YES_NO | wx.CANCEL)
271 else: 285 else:
272 - dlg = wx.MessageDialog(None, "Save changes to "+filename+"?", 286 + dlg = wx.MessageDialog(None, "Save changes to %s?"%filename,
273 "InVesalius 3", 287 "InVesalius 3",
274 wx.ICON_QUESTION | wx.YES_NO | wx.CANCEL) 288 wx.ICON_QUESTION | wx.YES_NO | wx.CANCEL)
275 289
@@ -288,10 +302,10 @@ def SaveChangesDialog2(filename): @@ -288,10 +302,10 @@ def SaveChangesDialog2(filename):
288 current_dir = os.path.abspath(".") 302 current_dir = os.path.abspath(".")
289 if sys.platform == 'darwin': 303 if sys.platform == 'darwin':
290 dlg = wx.MessageDialog(None, "", 304 dlg = wx.MessageDialog(None, "",
291 - "Save changes to "+filename+"?", 305 + "Save changes to %s?"%filename,
292 wx.ICON_QUESTION | wx.YES_NO) 306 wx.ICON_QUESTION | wx.YES_NO)
293 else: 307 else:
294 - dlg = wx.MessageDialog(None, "Save changes to "+filename+"?", 308 + dlg = wx.MessageDialog(None, "Save changes to %s?"%filename,
295 "InVesalius 3", 309 "InVesalius 3",
296 wx.ICON_QUESTION | wx.YES_NO) 310 wx.ICON_QUESTION | wx.YES_NO)
297 311