Commit c0cefa15923440b7d08102e18a219bfc749b32b3

Authored by Thiago Franco de Moraes
1 parent aad0e7da
Exists in phoenix

Dialogs adapted to phoenix

Showing 1 changed file with 170 additions and 94 deletions   Show diff stats
invesalius/gui/dialogs.py
... ... @@ -60,11 +60,17 @@ EVT_MASK_SET = wx.PyEventBinder(myEVT_MASK_SET, 1)
60 60  
61 61 class NumberDialog(wx.Dialog):
62 62 def __init__(self, message, value=0):
63   - pre = wx.PreDialog()
64   - pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize,
65   - pos=wx.DefaultPosition,
66   - style=wx.DEFAULT_DIALOG_STYLE)
67   - self.PostCreate(pre)
  63 + try:
  64 + pre = wx.PreDialog()
  65 + pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize,
  66 + pos=wx.DefaultPosition,
  67 + style=wx.DEFAULT_DIALOG_STYLE)
  68 + self.PostCreate(pre)
  69 + except AttributeError:
  70 + wx.Dialog.__init__(self)
  71 + self.Create(None, -1, "InVesalius 3", size=wx.DefaultSize,
  72 + pos=wx.DefaultPosition,
  73 + style=wx.DEFAULT_DIALOG_STYLE)
68 74  
69 75 # Static text which contains message to user
70 76 label = wx.StaticText(self, -1, message)
... ... @@ -110,11 +116,17 @@ class NumberDialog(wx.Dialog):
110 116 class ResizeImageDialog(wx.Dialog):
111 117  
112 118 def __init__(self):#, message, value=0):
113   - pre = self.pre = wx.PreDialog()
114   - pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize,
115   - pos=wx.DefaultPosition,
116   - style=wx.DEFAULT_DIALOG_STYLE)
117   - self.PostCreate(pre)
  119 + try:
  120 + pre = self.pre = wx.PreDialog()
  121 + pre.Create(None, -1, "InVesalius 3", size=wx.DefaultSize,
  122 + pos=wx.DefaultPosition,
  123 + style=wx.DEFAULT_DIALOG_STYLE)
  124 + self.PostCreate(pre)
  125 + except AttributeError:
  126 + wx.Dialog.__init__(self)
  127 + self.Create(None, -1, "InVesalius 3", size=wx.DefaultSize,
  128 + pos=wx.DefaultPosition,
  129 + style=wx.DEFAULT_DIALOG_STYLE)
118 130  
119 131 lbl_message = wx.StaticText(self, -1, _("InVesalius is running on a 32-bit operating system or has insufficient memory. \nIf you want to work with 3D surfaces or volume rendering, \nit is recommended to reduce the medical images resolution."))
120 132 icon = wx.ArtProvider.GetBitmap(wx.ART_WARNING, wx.ART_MESSAGE_BOX, (32,32))
... ... @@ -512,10 +524,16 @@ def ShowLoadMarkersDialog():
512 524  
513 525 class MessageDialog(wx.Dialog):
514 526 def __init__(self, message):
515   - pre = wx.PreDialog()
516   - pre.Create(None, -1, "InVesalius 3", size=(360, 370), pos=wx.DefaultPosition,
517   - style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)
518   - self.PostCreate(pre)
  527 + try:
  528 + pre = wx.PreDialog()
  529 + pre.Create(None, -1, "InVesalius 3", size=(360, 370), pos=wx.DefaultPosition,
  530 + style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)
  531 + self.PostCreate(pre)
  532 + except AttributeError:
  533 + wx.Dialog.__init__(self)
  534 + self.Create(None, -1, "InVesalius 3", size=(360, 370),
  535 + pos=wx.DefaultPosition,
  536 + style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)
519 537  
520 538 # Static text which contains message to user
521 539 label = wx.StaticText(self, -1, message)
... ... @@ -554,10 +572,15 @@ class UpdateMessageDialog(wx.Dialog):
554 572 title=_("Invesalius Update")
555 573 self.url = url
556 574  
557   - pre = wx.PreDialog()
558   - pre.Create(None, -1, title, size=(360, 370), pos=wx.DefaultPosition,
559   - style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)
560   - self.PostCreate(pre)
  575 + try:
  576 + pre = wx.PreDialog()
  577 + pre.Create(None, -1, title, size=(360, 370), pos=wx.DefaultPosition,
  578 + style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)
  579 + self.PostCreate(pre)
  580 + except AttributeError:
  581 + wx.Dialog.__init__(self)
  582 + self.Create(None, -1, title, size=(360, 370), pos=wx.DefaultPosition,
  583 + style=wx.DEFAULT_DIALOG_STYLE|wx.ICON_INFORMATION)
561 584  
562 585 # Static text which contains message to user
563 586 label = wx.StaticText(self, -1, msg)
... ... @@ -831,14 +854,19 @@ class NewMask(wx.Dialog):
831 854 # so we can set an extra style that must be set before
832 855 # creation, and then we create the GUI object using the Create
833 856 # method.
834   - pre = wx.PreDialog()
835   - pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
836   - pre.Create(parent, ID, title, pos, (500,300), style)
837   -
838   - # This next step is the most important, it turns this Python
839   - # object into the real wrapper of the dialog (instead of pre)
840   - # as far as the wxPython extension is concerned.
841   - self.PostCreate(pre)
  857 + try:
  858 + pre = wx.PreDialog()
  859 + pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
  860 + pre.Create(parent, ID, title, pos, (500,300), style)
  861 +
  862 + # This next step is the most important, it turns this Python
  863 + # object into the real wrapper of the dialog (instead of pre)
  864 + # as far as the wxPython extension is concerned.
  865 + self.PostCreate(pre)
  866 + except AttributeError:
  867 + wx.Dialog.__init__(self)
  868 + self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
  869 + self.Create(parent, ID, title, pos, (500,300), style)
842 870  
843 871 self.CenterOnScreen()
844 872  
... ... @@ -1104,18 +1132,23 @@ class NewSurfaceDialog(wx.Dialog):
1104 1132 import invesalius.data.surface as surface
1105 1133 import invesalius.project as prj
1106 1134  
1107   - # Instead of calling wx.Dialog.__init__ we precreate the dialog
1108   - # so we can set an extra style that must be set before
1109   - # creation, and then we create the GUI object using the Create
1110   - # method.
1111   - pre = wx.PreDialog()
1112   - pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
1113   - pre.Create(parent, ID, title, pos, (500,300), style)
1114   -
1115   - # This next step is the most important, it turns this Python
1116   - # object into the real wrapper of the dialog (instead of pre)
1117   - # as far as the wxPython extension is concerned.
1118   - self.PostCreate(pre)
  1135 + try:
  1136 + # Instead of calling wx.Dialog.__init__ we precreate the dialog
  1137 + # so we can set an extra style that must be set before
  1138 + # creation, and then we create the GUI object using the Create
  1139 + # method.
  1140 + pre = wx.PreDialog()
  1141 + pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
  1142 + pre.Create(parent, ID, title, pos, (500,300), style)
  1143 +
  1144 + # This next step is the most important, it turns this Python
  1145 + # object into the real wrapper of the dialog (instead of pre)
  1146 + # as far as the wxPython extension is concerned.
  1147 + self.PostCreate(pre)
  1148 + except AttributeError:
  1149 + wx.Dialog.__init__(self)
  1150 + self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
  1151 + self.Create(parent, ID, title, pos, (500,300), style)
1119 1152  
1120 1153 self.CenterOnScreen()
1121 1154  
... ... @@ -1313,22 +1346,31 @@ class SurfaceCreationDialog(wx.Dialog):
1313 1346 style=wx.DEFAULT_DIALOG_STYLE, useMetal=False,
1314 1347 mask_edited=False):
1315 1348  
1316   - # Instead of calling wx.Dialog.__init__ we precreate the dialog
1317   - # so we can set an extra style that must be set before
1318   - # creation, and then we create the GUI object using the Create
1319   - # method.
1320   - pre = wx.PreDialog()
1321   - pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
1322   - pre.Create(parent, ID, title, pos, (500,300), style)
1323   -
1324   - # This extra style can be set after the UI object has been created.
1325   - if 'wxMac' in wx.PlatformInfo and useMetal:
1326   - self.SetExtraStyle(wx.DIALOG_EX_METAL)
1327   -
1328   - # This next step is the most important, it turns this Python
1329   - # object into the real wrapper of the dialog (instead of pre)
1330   - # as far as the wxPython extension is concerned.
1331   - self.PostCreate(pre)
  1349 + try:
  1350 + # Instead of calling wx.Dialog.__init__ we precreate the dialog
  1351 + # so we can set an extra style that must be set before
  1352 + # creation, and then we create the GUI object using the Create
  1353 + # method.
  1354 + pre = wx.PreDialog()
  1355 + pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
  1356 + pre.Create(parent, ID, title, pos, (500,300), style)
  1357 +
  1358 + # This extra style can be set after the UI object has been created.
  1359 + if 'wxMac' in wx.PlatformInfo and useMetal:
  1360 + self.SetExtraStyle(wx.DIALOG_EX_METAL)
  1361 +
  1362 + # This next step is the most important, it turns this Python
  1363 + # object into the real wrapper of the dialog (instead of pre)
  1364 + # as far as the wxPython extension is concerned.
  1365 + self.PostCreate(pre)
  1366 + except AttributeError:
  1367 + wx.Dialog.__init__(self)
  1368 + self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
  1369 +
  1370 + if 'wxMac' in wx.PlatformInfo and useMetal:
  1371 + self.SetExtraStyle(wx.DIALOG_EX_METAL)
  1372 +
  1373 + self.Create(parent, ID, title, pos, (500,300), style)
1332 1374  
1333 1375 self.CenterOnScreen()
1334 1376  
... ... @@ -1625,9 +1667,13 @@ class SurfaceMethodPanel(wx.Panel):
1625 1667  
1626 1668 class ClutImagedataDialog(wx.Dialog):
1627 1669 def __init__(self, histogram, init, end, nodes=None):
1628   - pre = wx.PreDialog()
1629   - pre.Create(wx.GetApp().GetTopWindow(), -1, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
1630   - self.PostCreate(pre)
  1670 + try:
  1671 + pre = wx.PreDialog()
  1672 + pre.Create(wx.GetApp().GetTopWindow(), -1, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
  1673 + self.PostCreate(pre)
  1674 + except AttributeError:
  1675 + wx.Dialog.__init__(self)
  1676 + self.Create(wx.GetApp().GetTopWindow(), -1, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
1631 1677  
1632 1678 self.histogram = histogram
1633 1679 self.init = init
... ... @@ -1726,9 +1772,13 @@ class WatershedOptionsPanel(wx.Panel):
1726 1772  
1727 1773 class WatershedOptionsDialog(wx.Dialog):
1728 1774 def __init__(self, config):
1729   - pre = wx.PreDialog()
1730   - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u'Watershed'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
1731   - self.PostCreate(pre)
  1775 + try:
  1776 + pre = wx.PreDialog()
  1777 + pre.Create(wx.GetApp().GetTopWindow(), -1, _(u'Watershed'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
  1778 + self.PostCreate(pre)
  1779 + except AttributeError:
  1780 + wx.Dialog.__init__(self)
  1781 + self.Create(wx.GetApp().GetTopWindow(), -1, _(u'Watershed'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
1732 1782  
1733 1783 self.config = config
1734 1784  
... ... @@ -1767,9 +1817,13 @@ class WatershedOptionsDialog(wx.Dialog):
1767 1817  
1768 1818 class MaskBooleanDialog(wx.Dialog):
1769 1819 def __init__(self, masks):
1770   - pre = wx.PreDialog()
1771   - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Boolean operations"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)
1772   - self.PostCreate(pre)
  1820 + try:
  1821 + pre = wx.PreDialog()
  1822 + pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Boolean operations"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)
  1823 + self.PostCreate(pre)
  1824 + except AttributeError:
  1825 + wx.Dialog.__init__(self)
  1826 + self.Create(wx.GetApp().GetTopWindow(), -1, _(u"Boolean operations"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)
1773 1827  
1774 1828 self._init_gui(masks)
1775 1829 self.CenterOnScreen()
... ... @@ -1847,9 +1901,13 @@ class MaskBooleanDialog(wx.Dialog):
1847 1901  
1848 1902 class ReorientImageDialog(wx.Dialog):
1849 1903 def __init__(self):
1850   - pre = wx.PreDialog()
1851   - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u'Image reorientation'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
1852   - self.PostCreate(pre)
  1904 + try:
  1905 + pre = wx.PreDialog()
  1906 + pre.Create(wx.GetApp().GetTopWindow(), -1, _(u'Image reorientation'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
  1907 + self.PostCreate(pre)
  1908 + except AttributeError:
  1909 + wx.Dialog.__init__(self)
  1910 + self.Create(wx.GetApp().GetTopWindow(), -1, _(u'Image reorientation'), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
1853 1911  
1854 1912 self._init_gui()
1855 1913 self._bind_events()
... ... @@ -1914,20 +1972,22 @@ class ImportBitmapParameters(wx.Dialog):
1914 1972 from os import sys
1915 1973  
1916 1974 def __init__(self):
1917   - pre = wx.PreDialog()
1918   -
1919 1975 if sys.platform == 'win32':
1920 1976 size=wx.Size(380,180)
1921 1977 else:
1922 1978 size=wx.Size(380,210)
1923 1979  
1924   - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Create project from bitmap"),size=size,\
1925   - style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)
  1980 + try:
  1981 + pre = wx.PreDialog()
  1982 + pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Create project from bitmap"),size=size,\
  1983 + style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)
  1984 + self.PostCreate(pre)
  1985 + except AttributeError:
  1986 + wx.Dialog.__init__(self)
  1987 + self.Create(wx.GetApp().GetTopWindow(), -1, _(u"Create project from bitmap"),size=size,\
  1988 + style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.STAY_ON_TOP)
1926 1989  
1927 1990 self.interval = 0
1928   -
1929   - self.PostCreate(pre)
1930   -
1931 1991 self._init_gui()
1932 1992  
1933 1993 self.bind_evts()
... ... @@ -2314,9 +2374,13 @@ class PanelFFillConfidence(wx.Panel):
2314 2374  
2315 2375 class FFillOptionsDialog(wx.Dialog):
2316 2376 def __init__(self, title, config):
2317   - pre = wx.PreDialog()
2318   - pre.Create(wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
2319   - self.PostCreate(pre)
  2377 + try:
  2378 + pre = wx.PreDialog()
  2379 + pre.Create(wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
  2380 + self.PostCreate(pre)
  2381 + except AttributeError:
  2382 + wx.Dialog.__init__(self)
  2383 + self.Create(wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
2320 2384  
2321 2385 self.config = config
2322 2386  
... ... @@ -2424,9 +2488,13 @@ class FFillOptionsDialog(wx.Dialog):
2424 2488  
2425 2489 class SelectPartsOptionsDialog(wx.Dialog):
2426 2490 def __init__(self, config):
2427   - pre = wx.PreDialog()
2428   - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Select mask parts"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
2429   - self.PostCreate(pre)
  2491 + try:
  2492 + pre = wx.PreDialog()
  2493 + pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Select mask parts"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
  2494 + self.PostCreate(pre)
  2495 + except AttributeError:
  2496 + wx.Dialog.__init__(self)
  2497 + self.Create(wx.GetApp().GetTopWindow(), -1, _(u"Select mask parts"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
2430 2498  
2431 2499 self.config = config
2432 2500  
... ... @@ -2506,9 +2574,13 @@ class SelectPartsOptionsDialog(wx.Dialog):
2506 2574  
2507 2575 class FFillSegmentationOptionsDialog(wx.Dialog):
2508 2576 def __init__(self, config):
2509   - pre = wx.PreDialog()
2510   - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Region growing"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
2511   - self.PostCreate(pre)
  2577 + try:
  2578 + pre = wx.PreDialog()
  2579 + pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Region growing"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
  2580 + self.PostCreate(pre)
  2581 + except AttributeError:
  2582 + wx.Dialog.__init__(self)
  2583 + self.Create(wx.GetApp().GetTopWindow(), -1, _(u"Region growing"), style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
2512 2584  
2513 2585 self.config = config
2514 2586  
... ... @@ -2682,22 +2754,22 @@ class FFillSegmentationOptionsDialog(wx.Dialog):
2682 2754  
2683 2755  
2684 2756 class CropOptionsDialog(wx.Dialog):
2685   -
2686 2757 def __init__(self, config):
2687   -
2688 2758 self.config = config
2689   -
2690   - pre = wx.PreDialog()
2691   -
2692 2759 if sys.platform == 'win32':
2693 2760 size=wx.Size(204,165)
2694 2761 else:
2695 2762 size=wx.Size(205,180)
2696 2763  
2697   - pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Crop mask"),\
2698   - size=size, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
2699   -
2700   - self.PostCreate(pre)
  2764 + try:
  2765 + pre = wx.PreDialog()
  2766 + pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Crop mask"),\
  2767 + size=size, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
  2768 + self.PostCreate(pre)
  2769 + except AttributeError:
  2770 + wx.Dialog.__init__(self)
  2771 + self.Create(wx.GetApp().GetTopWindow(), -1, _(u"Crop mask"),\
  2772 + size=size, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
2701 2773  
2702 2774 self._init_gui()
2703 2775 #self.config = config
... ... @@ -2807,9 +2879,13 @@ class CropOptionsDialog(wx.Dialog):
2807 2879  
2808 2880 class FillHolesAutoDialog(wx.Dialog):
2809 2881 def __init__(self, title):
2810   - pre = wx.PreDialog()
2811   - pre.Create(wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
2812   - self.PostCreate(pre)
  2882 + try:
  2883 + pre = wx.PreDialog()
  2884 + pre.Create(wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
  2885 + self.PostCreate(pre)
  2886 + except AttributeError:
  2887 + wx.Dialog.__init__(self)
  2888 + self.Create(wx.GetApp().GetTopWindow(), -1, title, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT)
2813 2889  
2814 2890 self._init_gui()
2815 2891  
... ...