Ticket #1035: modal_dForm.patch
| File modal_dForm.patch, 4.6 kB (added by paul, 2 years ago) |
|---|
-
dabo/lib/datanav2/Form.py
old new 44 44 # Create the various elements: 45 45 self.setupPageFrame() 46 46 47 if not self.Testing :47 if not self.Testing and not self.Modal: 48 48 self.setupToolBar() 49 49 self.setupMenu() 50 50 -
dabo/ui/uiwx/dPemMixin.py
old new 1144 1144 1145 1145 def show(self): 1146 1146 """Make the object visible.""" 1147 self. Show(True)1147 self.Visible = True 1148 1148 1149 1149 1150 1150 def hide(self): … … 2246 2246 2247 2247 def _setVisible(self, val): 2248 2248 if self._constructed(): 2249 val = bool(val) 2250 self.Show(val) 2251 if not val: 2252 if getattr(self, "_shownModal", False): 2253 ## This is a form that was shown modally. Need to undo that 2254 ## when the form goes hidden. 2255 self.MakeModal(False) 2256 self._shownModal = False 2249 self.Show(bool(val)) 2257 2250 else: 2258 2251 self._properties["Visible"] = val 2259 2252 -
dabo/ui/uiwx/dFormMixin.py
old new 283 283 """ 284 284 raise dException.FeatureNotSupportedException, \ 285 285 _("The underlying UI toolkit does not support modal forms. Use a dDialog instead.") 286 #self.MakeModal(True)287 #self._isModal = self.Visible = True288 286 289 287 290 288 def release(self): … … 945 943 946 944 MenuBarFile = property(_getMenuBarFile, _setMenuBarFile, None, 947 945 _("Path to the .mnxml file that defines this form's menu bar (str)")) 948 946 949 947 SaveRestorePosition = property(_getSaveRestorePosition, 950 948 _setSaveRestorePosition, None, 951 949 _("""Specifies whether the form's position and size as set by the user -
dabo/ui/uiwx/dForm.py
old new 775 775 def __init__(self, parent=None, properties=None, attProperties=None, *args, **kwargs): 776 776 self._baseClass = dForm 777 777 778 if dabo.settings.MDI and isinstance(parent, wx.MDIParentFrame):779 # Hack this into a n MDI Child:780 dForm.__bases__ = (BaseForm, wx. MDIChildFrame)781 preClass = wx.Pre MDIChildFrame782 self._m di= True778 if kwargs.pop("Modal", False): 779 # Hack this into a wx.Dialog, for true modality 780 dForm.__bases__ = (BaseForm, wx.Dialog) 781 preClass = wx.PreDialog 782 self._modal = True 783 783 else: 784 # This is a normal SDI form: 785 dForm.__bases__ = (BaseForm, wx.Frame) 786 preClass = wx.PreFrame 787 self._mdi = False 788 ## (Note that it is necessary to run the above block each time, because 784 # Normal dForm 785 if dabo.settings.MDI and isinstance(parent, wx.MDIParentFrame): 786 # Hack this into an MDI Child: 787 dForm.__bases__ = (BaseForm, wx.MDIChildFrame) 788 preClass = wx.PreMDIChildFrame 789 self._mdi = True 790 else: 791 # This is a normal SDI form: 792 dForm.__bases__ = (BaseForm, wx.Frame) 793 preClass = wx.PreFrame 794 self._mdi = False 795 796 ## (Note that it is necessary to run the above blocks each time, because 789 797 ## we are modifying the dForm class definition globally.) 790 798 BaseForm.__init__(self, preClass, parent, properties, attProperties, *args, **kwargs) 791 799 … … 797 805 super(dForm, self).Layout() 798 806 wx.CallAfter(self.update) 799 807 808 def _getModal(self): 809 return getattr(self, "_modal", False) 800 810 811 def _getVisible(self): 812 return self.IsShown() 813 814 def _setVisible(self, val): 815 if self._constructed(): 816 val = bool(val) 817 if val and self.Modal: 818 self.ShowModal() 819 else: 820 self.Show(val) 821 else: 822 self._properties["Visible"] = val 823 824 Modal = property(_getModal, None, None, 825 _("""Specifies whether this dForm is modal or not (bool) 826 827 A modal dForm runs its own event loop, blocking program flow until the 828 form is hidden or closed, exactly like a dDialog does it. This property 829 may only be sent to the constructor, and once instantiated you may not 830 change the modality of a form. For example, 831 frm = dabo.ui.dForm(Modal=True) 832 will create a modal form. 833 834 Note that a modal dForm is actually a dDialog, and as such does not 835 have the ability to contain MenuBars, StatusBars, or ToolBars.""")) 836 837 Visible = property(_getVisible, _setVisible, None, 838 _("Specifies whether the form is shown or hidden. (bool)") ) 839 840 841 801 842 class dToolForm(BaseForm, wx.MiniFrame): 802 843 def __init__(self, parent=None, properties=None, attProperties=None, *args, **kwargs): 803 844 self._baseClass = dToolForm
