Commit 1ba0ba6abf07b9aba83bcd2c5343e255231f1292

Authored by tatiana
1 parent 0d35b560

FIX: Import directory without dicom files (#82)

Showing 2 changed files with 27 additions and 14 deletions   Show diff stats
invesalius/control.py
... ... @@ -246,18 +246,21 @@ class Controller():
246 246  
247 247 def OnLoadImportPanel(self, evt):
248 248 patient_series = evt.data
249   - self.LoadImportPanel(patient_series)
250   - ps.Publisher().sendMessage('Show import panel')
251   - ps.Publisher().sendMessage("Show import panel in frame")
  249 + ok = self.LoadImportPanel(patient_series)
  250 + if ok:
  251 + ps.Publisher().sendMessage('Show import panel')
  252 + ps.Publisher().sendMessage("Show import panel in frame")
252 253  
253 254  
254 255 def LoadImportPanel(self, patient_series):
255   - if isinstance(patient_series, list):
  256 + if patient_series and isinstance(patient_series, list):
256 257 ps.Publisher().sendMessage("Load import panel", patient_series)
257 258 first_patient = patient_series[0]
258 259 ps.Publisher().sendMessage("Load dicom preview", first_patient)
  260 + return True
259 261 else:
260   - print "No DICOM files on directory"
  262 + dialog.ImportInvalidFiles()
  263 + return False
261 264  
262 265 def OnImportMedicalImages(self, pubsub_evt):
263 266 directory = pubsub_evt.data
... ...
invesalius/gui/dialogs.py
... ... @@ -263,27 +263,37 @@ def SaveChangesDialog__Old(filename):
263 263  
264 264  
265 265 def ImportEmptyDirectory(dirpath):
  266 + msg = "%s is an empty directory." % dirpath
266 267 if sys.platform == 'darwin':
267 268 dlg = wx.MessageDialog(None, "",
268   - "%s is an empty directory." % dirpath,
  269 + msg,
269 270 wx.ICON_INFORMATION | wx.OK)
270 271 else:
271   - dlg = wx.MessageDialog(None, "%s is an empty directory." % dirpath,
  272 + dlg = wx.MessageDialog(None, msg,
272 273 "InVesalius 3",
273 274 wx.ICON_INFORMATION | wx.OK)
274 275 dlg.ShowModal()
275 276 dlg.Destroy()
276 277  
277   -
  278 +def ImportInvalidFiles():
  279 + msg = "There are no DICOM files on the selected directory."
  280 + if sys.platform == 'darwin':
  281 + dlg = wx.MessageDialog(None, "", msg,
  282 + wx.ICON_INFORMATION | wx.OK)
  283 + else:
  284 + dlg = wx.MessageDialog(None, msg, "InVesalius 3",
  285 + wx.ICON_INFORMATION | wx.OK)
  286 + dlg.ShowModal()
  287 + dlg.Destroy()
278 288  
279 289 def SaveChangesDialog(filename):
280 290 current_dir = os.path.abspath(".")
  291 + msg = "Save changes to %s?"%filename
281 292 if sys.platform == 'darwin':
282   - dlg = wx.MessageDialog(None, "",
283   - "Save changes to %s?"%filename,
  293 + dlg = wx.MessageDialog(None, "", msg,
284 294 wx.ICON_QUESTION | wx.YES_NO | wx.CANCEL)
285 295 else:
286   - dlg = wx.MessageDialog(None, "Save changes to %s?"%filename,
  296 + dlg = wx.MessageDialog(None, msg,
287 297 "InVesalius 3",
288 298 wx.ICON_QUESTION | wx.YES_NO | wx.CANCEL)
289 299  
... ... @@ -300,12 +310,12 @@ def SaveChangesDialog(filename):
300 310  
301 311 def SaveChangesDialog2(filename):
302 312 current_dir = os.path.abspath(".")
  313 + msg = "Save changes to %s?"%filename
303 314 if sys.platform == 'darwin':
304   - dlg = wx.MessageDialog(None, "",
305   - "Save changes to %s?"%filename,
  315 + dlg = wx.MessageDialog(None, "", msg,
306 316 wx.ICON_QUESTION | wx.YES_NO)
307 317 else:
308   - dlg = wx.MessageDialog(None, "Save changes to %s?"%filename,
  318 + dlg = wx.MessageDialog(None, msg,
309 319 "InVesalius 3",
310 320 wx.ICON_QUESTION | wx.YES_NO)
311 321  
... ...