Commit 1e05ec1ef8309206beb5a0a919640cd5f5fc1763
Exists in
master
Merge branch 'master' into icp
Showing
3 changed files
with
39 additions
and
11 deletions
Show diff stats
invesalius/gui/brain_seg_dialog.py
@@ -16,6 +16,7 @@ from pubsub import pub as Publisher | @@ -16,6 +16,7 @@ from pubsub import pub as Publisher | ||
16 | 16 | ||
17 | import invesalius.data.slice_ as slc | 17 | import invesalius.data.slice_ as slc |
18 | from invesalius.segmentation.brain import segment, utils | 18 | from invesalius.segmentation.brain import segment, utils |
19 | +from invesalius.gui import dialogs | ||
19 | 20 | ||
20 | HAS_THEANO = bool(importlib.util.find_spec("theano")) | 21 | HAS_THEANO = bool(importlib.util.find_spec("theano")) |
21 | HAS_PLAIDML = bool(importlib.util.find_spec("plaidml")) | 22 | HAS_PLAIDML = bool(importlib.util.find_spec("plaidml")) |
@@ -237,13 +238,13 @@ class BrainSegmenterDialog(wx.Dialog): | @@ -237,13 +238,13 @@ class BrainSegmenterDialog(wx.Dialog): | ||
237 | except (multiprocessing.ProcessError, OSError, ValueError) as err: | 238 | except (multiprocessing.ProcessError, OSError, ValueError) as err: |
238 | self.OnStop(None) | 239 | self.OnStop(None) |
239 | self.HideProgress() | 240 | self.HideProgress() |
240 | - dlg = wx.MessageDialog( | 241 | + dlg = dialogs.ErrorMessageBox( |
241 | None, | 242 | None, |
242 | "It was not possible to start brain segmentation because:" | 243 | "It was not possible to start brain segmentation because:" |
243 | + "\n" | 244 | + "\n" |
244 | + str(err), | 245 | + str(err), |
245 | "Brain segmentation error", | 246 | "Brain segmentation error", |
246 | - wx.ICON_ERROR | wx.OK, | 247 | + # wx.ICON_ERROR | wx.OK, |
247 | ) | 248 | ) |
248 | dlg.ShowModal() | 249 | dlg.ShowModal() |
249 | 250 | ||
@@ -280,15 +281,15 @@ class BrainSegmenterDialog(wx.Dialog): | @@ -280,15 +281,15 @@ class BrainSegmenterDialog(wx.Dialog): | ||
280 | error, traceback = self.ps.exception | 281 | error, traceback = self.ps.exception |
281 | self.OnStop(None) | 282 | self.OnStop(None) |
282 | self.HideProgress() | 283 | self.HideProgress() |
283 | - dlg = wx.MessageDialog( | 284 | + dlg = dialogs.ErrorMessageBox( |
284 | None, | 285 | None, |
286 | + "Brain segmentation error", | ||
285 | "It was not possible to use brain segmentation because:" | 287 | "It was not possible to use brain segmentation because:" |
286 | + "\n" | 288 | + "\n" |
287 | + str(error) | 289 | + str(error) |
288 | + "\n" | 290 | + "\n" |
289 | + traceback, | 291 | + traceback, |
290 | - "Brain segmentation error", | ||
291 | - wx.ICON_ERROR | wx.OK, | 292 | + # wx.ICON_ERROR | wx.OK, |
292 | ) | 293 | ) |
293 | dlg.ShowModal() | 294 | dlg.ShowModal() |
294 | return | 295 | return |
invesalius/gui/dialogs.py
@@ -668,8 +668,8 @@ class MessageBox(wx.Dialog): | @@ -668,8 +668,8 @@ class MessageBox(wx.Dialog): | ||
668 | btnsizer.Realize() | 668 | btnsizer.Realize() |
669 | 669 | ||
670 | sizer = wx.BoxSizer(wx.VERTICAL) | 670 | sizer = wx.BoxSizer(wx.VERTICAL) |
671 | - sizer.Add(title_label, 0, wx.ALIGN_CENTRE|wx.ALL|wx.EXPAND, 5) | ||
672 | - sizer.Add(text, 1, wx.ALIGN_CENTRE|wx.ALL|wx.EXPAND, 5) | 671 | + sizer.Add(title_label, 0, wx.ALL | wx.EXPAND, 5) |
672 | + sizer.Add(text, 1, wx.ALL | wx.EXPAND, 5) | ||
673 | sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND|wx.ALL, 5) | 673 | sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND|wx.ALL, 5) |
674 | self.SetSizer(sizer) | 674 | self.SetSizer(sizer) |
675 | sizer.Fit(self) | 675 | sizer.Fit(self) |
@@ -677,6 +677,33 @@ class MessageBox(wx.Dialog): | @@ -677,6 +677,33 @@ class MessageBox(wx.Dialog): | ||
677 | self.ShowModal() | 677 | self.ShowModal() |
678 | 678 | ||
679 | 679 | ||
680 | +class ErrorMessageBox(wx.Dialog): | ||
681 | + def __init__(self, parent, title, message, caption="InVesalius3 Error"): | ||
682 | + wx.Dialog.__init__(self, parent, title=caption, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) | ||
683 | + | ||
684 | + title_label = wx.StaticText(self, -1, title) | ||
685 | + | ||
686 | + text = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_READONLY|wx.BORDER_NONE) | ||
687 | + text.SetValue(message) | ||
688 | + text.SetBackgroundColour(wx.SystemSettings.GetColour(4)) | ||
689 | + | ||
690 | + width, height = text.GetTextExtent("M"*60) | ||
691 | + text.SetMinSize((width, -1)) | ||
692 | + | ||
693 | + btn_ok = wx.Button(self, wx.ID_OK) | ||
694 | + btnsizer = wx.StdDialogButtonSizer() | ||
695 | + btnsizer.AddButton(btn_ok) | ||
696 | + btnsizer.Realize() | ||
697 | + | ||
698 | + sizer = wx.BoxSizer(wx.VERTICAL) | ||
699 | + sizer.Add(title_label, 0, wx.ALL | wx.EXPAND, 5) | ||
700 | + sizer.Add(text, 1, wx.ALL | wx.EXPAND, 5) | ||
701 | + sizer.Add(btnsizer, 0, wx.EXPAND | wx.ALL, 5) | ||
702 | + self.SetSizer(sizer) | ||
703 | + sizer.Fit(self) | ||
704 | + self.Center() | ||
705 | + | ||
706 | + | ||
680 | def SaveChangesDialog__Old(filename): | 707 | def SaveChangesDialog__Old(filename): |
681 | message = _("The project %s has been modified.\nSave changes?")%filename | 708 | message = _("The project %s has been modified.\nSave changes?")%filename |
682 | dlg = MessageDialog(message) | 709 | dlg = MessageDialog(message) |
invesalius/gui/task_navigator.py
@@ -215,10 +215,10 @@ class InnerFoldPanel(wx.Panel): | @@ -215,10 +215,10 @@ class InnerFoldPanel(wx.Panel): | ||
215 | checkobj.Bind(wx.EVT_CHECKBOX, self.OnShowObject) | 215 | checkobj.Bind(wx.EVT_CHECKBOX, self.OnShowObject) |
216 | self.checkobj = checkobj | 216 | self.checkobj = checkobj |
217 | 217 | ||
218 | - if sys.platform != 'win32': | ||
219 | - self.checkcamera.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | ||
220 | - checktrigger.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | ||
221 | - checkobj.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | 218 | + # if sys.platform != 'win32': |
219 | + self.checkcamera.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | ||
220 | + checktrigger.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | ||
221 | + checkobj.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) | ||
222 | 222 | ||
223 | line_sizer = wx.BoxSizer(wx.HORIZONTAL) | 223 | line_sizer = wx.BoxSizer(wx.HORIZONTAL) |
224 | line_sizer.Add(checkcamera, 0, wx.ALIGN_LEFT | wx.RIGHT | wx.LEFT, 5) | 224 | line_sizer.Add(checkcamera, 0, wx.ALIGN_LEFT | wx.RIGHT | wx.LEFT, 5) |