Commit 1ba0ba6abf07b9aba83bcd2c5343e255231f1292
1 parent
0d35b560
Exists in
master
and in
6 other branches
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,18 +246,21 @@ class Controller(): | ||
246 | 246 | ||
247 | def OnLoadImportPanel(self, evt): | 247 | def OnLoadImportPanel(self, evt): |
248 | patient_series = evt.data | 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 | def LoadImportPanel(self, patient_series): | 255 | def LoadImportPanel(self, patient_series): |
255 | - if isinstance(patient_series, list): | 256 | + if patient_series and isinstance(patient_series, list): |
256 | ps.Publisher().sendMessage("Load import panel", patient_series) | 257 | ps.Publisher().sendMessage("Load import panel", patient_series) |
257 | first_patient = patient_series[0] | 258 | first_patient = patient_series[0] |
258 | ps.Publisher().sendMessage("Load dicom preview", first_patient) | 259 | ps.Publisher().sendMessage("Load dicom preview", first_patient) |
260 | + return True | ||
259 | else: | 261 | else: |
260 | - print "No DICOM files on directory" | 262 | + dialog.ImportInvalidFiles() |
263 | + return False | ||
261 | 264 | ||
262 | def OnImportMedicalImages(self, pubsub_evt): | 265 | def OnImportMedicalImages(self, pubsub_evt): |
263 | directory = pubsub_evt.data | 266 | directory = pubsub_evt.data |
invesalius/gui/dialogs.py
@@ -263,27 +263,37 @@ def SaveChangesDialog__Old(filename): | @@ -263,27 +263,37 @@ def SaveChangesDialog__Old(filename): | ||
263 | 263 | ||
264 | 264 | ||
265 | def ImportEmptyDirectory(dirpath): | 265 | def ImportEmptyDirectory(dirpath): |
266 | + msg = "%s is an empty directory." % dirpath | ||
266 | if sys.platform == 'darwin': | 267 | if sys.platform == 'darwin': |
267 | dlg = wx.MessageDialog(None, "", | 268 | dlg = wx.MessageDialog(None, "", |
268 | - "%s is an empty directory." % dirpath, | 269 | + msg, |
269 | wx.ICON_INFORMATION | wx.OK) | 270 | wx.ICON_INFORMATION | wx.OK) |
270 | else: | 271 | else: |
271 | - dlg = wx.MessageDialog(None, "%s is an empty directory." % dirpath, | 272 | + dlg = wx.MessageDialog(None, msg, |
272 | "InVesalius 3", | 273 | "InVesalius 3", |
273 | wx.ICON_INFORMATION | wx.OK) | 274 | wx.ICON_INFORMATION | wx.OK) |
274 | dlg.ShowModal() | 275 | dlg.ShowModal() |
275 | dlg.Destroy() | 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 | def SaveChangesDialog(filename): | 289 | def SaveChangesDialog(filename): |
280 | current_dir = os.path.abspath(".") | 290 | current_dir = os.path.abspath(".") |
291 | + msg = "Save changes to %s?"%filename | ||
281 | if sys.platform == 'darwin': | 292 | if sys.platform == 'darwin': |
282 | - dlg = wx.MessageDialog(None, "", | ||
283 | - "Save changes to %s?"%filename, | 293 | + dlg = wx.MessageDialog(None, "", msg, |
284 | wx.ICON_QUESTION | wx.YES_NO | wx.CANCEL) | 294 | wx.ICON_QUESTION | wx.YES_NO | wx.CANCEL) |
285 | else: | 295 | else: |
286 | - dlg = wx.MessageDialog(None, "Save changes to %s?"%filename, | 296 | + dlg = wx.MessageDialog(None, msg, |
287 | "InVesalius 3", | 297 | "InVesalius 3", |
288 | wx.ICON_QUESTION | wx.YES_NO | wx.CANCEL) | 298 | wx.ICON_QUESTION | wx.YES_NO | wx.CANCEL) |
289 | 299 | ||
@@ -300,12 +310,12 @@ def SaveChangesDialog(filename): | @@ -300,12 +310,12 @@ def SaveChangesDialog(filename): | ||
300 | 310 | ||
301 | def SaveChangesDialog2(filename): | 311 | def SaveChangesDialog2(filename): |
302 | current_dir = os.path.abspath(".") | 312 | current_dir = os.path.abspath(".") |
313 | + msg = "Save changes to %s?"%filename | ||
303 | if sys.platform == 'darwin': | 314 | if sys.platform == 'darwin': |
304 | - dlg = wx.MessageDialog(None, "", | ||
305 | - "Save changes to %s?"%filename, | 315 | + dlg = wx.MessageDialog(None, "", msg, |
306 | wx.ICON_QUESTION | wx.YES_NO) | 316 | wx.ICON_QUESTION | wx.YES_NO) |
307 | else: | 317 | else: |
308 | - dlg = wx.MessageDialog(None, "Save changes to %s?"%filename, | 318 | + dlg = wx.MessageDialog(None, msg, |
309 | "InVesalius 3", | 319 | "InVesalius 3", |
310 | wx.ICON_QUESTION | wx.YES_NO) | 320 | wx.ICON_QUESTION | wx.YES_NO) |
311 | 321 |