dabo Commit
Revision 1496
Date: 2005-10-31 16:13:32 -0800 (Mon, 31 Oct 2005)
Author: paul
Changed:
U trunk/dabo/lib/datanav/Form.py
U trunk/dabo/settings.py
U trunk/dabo/ui/uiwx/__init__.py
U trunk/dabo/ui/uiwx/dForm.py
U trunk/dabo/ui/uiwx/dFormMain.py
Log:
I'm working on having the ability to make MDI apps again, and the first step
seemed to be to provide separate classes for the different types: MDI parent
or child, or SDI.
Also added a global MDI attribute to dabo.settings. It'll work: place
dabo.settings.MDI right after your first dabo import, and all dForms
will be MDI children. However, a segfault will happen on Linux at least
if you don't make that form a child of dFormMain (which will be a
MDI parent). You can demo this most easily with appRecipes.
Diff:
Modified: trunk/dabo/lib/datanav/Form.py
===================================================================
--- trunk/dabo/lib/datanav/Form.py 2005-10-31 23:52:27 UTC (rev 1495)
+++ trunk/dabo/lib/datanav/Form.py 2005-11-01 00:13:32 UTC (rev 1496)
@@ -66,7 +66,6 @@
self.rowCount = 0
def _afterInit(self):
- #Form.doDefault()
super(Form, self)._afterInit()
if self.FormType == 'PickList':
# Map escape key to close the form
@@ -86,7 +85,6 @@
if dataSource is None:
if self.saveCancelRequeryAll:
dataSource = self._mainTable
- #return Form.doDefault(dataSource)
return super(Form, self).save(dataSource)
Modified: trunk/dabo/settings.py
===================================================================
--- trunk/dabo/settings.py 2005-10-31 23:52:27 UTC (rev 1495)
+++ trunk/dabo/settings.py 2005-11-01 00:13:32 UTC (rev 1496)
@@ -62,6 +62,22 @@
autoBindEvents = True
+# If you set MDI to True, then dFormMain and dForm will default to being MDI
+# parent and MDI child, respectively. IOW, you don't have to change your dForm
+# and dFormMain subclasses to inherit from dFormChildMDI, etc., but it comes at
+# the cost of being a global setting. This must be set before dabo.ui is
+# imported (ie right at the top of your app). Note that you could instead
choose
+# to deal with MDI/SDI explicitly in your form subclasses. IOW:
+# class MyForm(dabo.ui.dFormChildMDI)
+# class MyForm(dabo.ui.dFormParentMDI)
+# class MyForm(dabo.ui.dFormSDI)
+#
+# All the MDI setting does is make dFormMain == (dFormMainSDI or
dFormMainParentMDI)
+# and dForm == (dFormSDI or dFormChildMDI)
+MDI = False
+
+
+
### Settings - end
# Do not copy/paste anything below this line into settings_override.py.
Modified: trunk/dabo/ui/uiwx/__init__.py
===================================================================
--- trunk/dabo/ui/uiwx/__init__.py 2005-10-31 23:52:27 UTC (rev 1495)
+++ trunk/dabo/ui/uiwx/__init__.py 2005-11-01 00:13:32 UTC (rev 1496)
@@ -72,8 +72,13 @@
from dFileDialog import dSaveDialog
from dFontDialog import dFontDialog
from dForm import dForm
+from dForm import dFormSDI
+from dForm import dFormChildMDI
+from dForm import dFormParentMDI
from dForm import dToolForm
from dFormMain import dFormMain
+from dFormMain import dFormMainSDI
+from dFormMain import dFormMainParentMDI
from dGauge import dGauge
from dGrid import dGrid
from dGrid import dColumn
Modified: trunk/dabo/ui/uiwx/dForm.py
===================================================================
--- trunk/dabo/ui/uiwx/dForm.py 2005-10-31 23:52:27 UTC (rev 1495)
+++ trunk/dabo/ui/uiwx/dForm.py 2005-11-01 00:13:32 UTC (rev 1496)
@@ -9,34 +9,15 @@
import time
import sys
-# Different platforms expect different frame types. Notably,
-# most users on Windows expect and prefer the MDI parent/child
-# type frames.
-# pkm 06/09/2004: disabled MDI even on Windows. There are some issues that I
-# don't have time to track down right now... better if it works
-# on Windows similarly to Linux instead of not at all... if you
-# want to enable MDI on Windows, just take out the "False and"
-# in the below if statement, and do the same in dFormMain.py.
-
-if False and wx.Platform == "__WXMSW__":
- wxFrameClass = wx.MDIChildFrame
- wxPreFrameClass = wx.PreMDIChildFrame
-else:
- wxFrameClass = wx.Frame
- wxPreFrameClass = wx.PreFrame
-
-
-class dForm(wxFrameClass, fm.dFormMixin):
+class dFormBase(fm.dFormMixin):
""" Create a dForm object, which is a bizobj-aware form.
dForm knows how to handle one or more dBizobjs, providing proxy methods
like next(), last(), save(), and requery().
"""
- def __init__(self, parent=None, properties=None, *args, **kwargs):
- self._baseClass = dForm
- preClass = wxPreFrameClass
-
+
+ def __init__(self, preClass, parent, properties, *args, **kwargs):
self.bizobjs = {}
self._primaryBizobj = None
@@ -76,7 +57,7 @@
mp = self.mainPanel = dabo.ui.dPanel(self)
self.Sizer.append(mp, 1, "x")
mp.Sizer = dabo.ui.dSizer(self.Sizer.Orientation)
- super(dForm, self)._afterInit()
+ super(dFormBase, self)._afterInit()
def show(self):
@@ -97,7 +78,7 @@
self.activeControlValid()
ret = self.confirmChanges()
if ret:
- ret = super(dForm, self)._beforeClose(evt)
+ ret = super(dFormBase, self)._beforeClose(evt)
return ret
@@ -732,9 +713,34 @@
_("Specifies whether dataset is row- or table-buffered.
(bool)") )
+class dFormSDI(wx.Frame, dFormBase):
+ def __init__(self, parent=None, properties=None, *args, **kwargs):
+ self._baseClass = dForm
+ preClass = wx.PreFrame
+ dFormBase.__init__(self, preClass, parent, properties, *args,
**kwargs)
-class dToolForm(dForm):
+
+class dFormParentMDI(wx.MDIParentFrame, dFormBase):
def __init__(self, parent=None, properties=None, *args, **kwargs):
+ self._baseClass = dForm
+ preClass = wx.PreMDIParentFrame
+ dFormBase.__init__(self, preClass, parent, properties, *args,
**kwargs)
+
+
+class dFormChildMDI(wx.MDIChildFrame, dFormBase):
+ def __init__(self, parent=None, properties=None, *args, **kwargs):
+ self._baseClass = dForm
+ preClass = wx.PreMDIChildFrame
+ dFormBase.__init__(self, preClass, parent, properties, *args,
**kwargs)
+
+if dabo.settings.MDI:
+ dForm = dFormChildMDI
+else:
+ dForm = dFormSDI
+
+
+class dToolForm(dFormSDI):
+ def __init__(self, parent=None, properties=None, *args, **kwargs):
style = self._extractKey(kwargs, "style", 0)
style = style | wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP |
wx.RESIZE_BORDER
kwargs["style"] = style
Modified: trunk/dabo/ui/uiwx/dFormMain.py
===================================================================
--- trunk/dabo/ui/uiwx/dFormMain.py 2005-10-31 23:52:27 UTC (rev 1495)
+++ trunk/dabo/ui/uiwx/dFormMain.py 2005-11-01 00:13:32 UTC (rev 1496)
@@ -6,30 +6,11 @@
import time
-# Different platforms expect different frame types. Notably,
-# most users on Windows expect and prefer the MDI parent/child
-# type frames.
-## pkm 06/09/2004: disabled MDI even on Windows. There are some issues that I
-## don't have time to track down right now... better if it works
-## on Windows similarly to Linux instead of not at all... if you
-## want to enable MDI on Windows, just take out the "False and"
-## in the below if statement, and do the same in dForm.py.
-
-#if False and wx.Platform == '__WXMSW__': # Microsoft Windows
-if True:
- wxFrameClass = wx.MDIParentFrame
- wxPreFrameClass = wx.PreMDIParentFrame
-else:
- wxFrameClass = wx.Frame
- wxPreFrameClass = wx.PreFrame
-
-class dFormMain(wxFrameClass, fm.dFormMixin):
+class dFormMainBase(fm.dFormMixin):
""" This is the main top-level form for the application.
"""
- def __init__(self, parent=None, properties=None, *args, **kwargs):
- self._baseClass = dFormMain
- preClass = wxPreFrameClass
+ def __init__(self, preClass, parent=None, properties=None, *args,
**kwargs):
fm.dFormMixin.__init__(self, preClass, parent, properties,
*args, **kwargs)
self.Size = (640,480)
@@ -45,7 +26,7 @@
def afterInit(self):
- super(dFormMain, self).afterInit()
+ super(dFormMainBase, self).afterInit()
## caption and status text handled in uiApp now
#self.Caption = "Dabo"
#self.setStatusText("Welcome to Dabo!")
@@ -101,6 +82,26 @@
wd,ht = dc.GetSize()
dc.DrawBitmap(self.bitmap, 10, (ht - 110))
+
+class dFormMainSDI(wx.Frame, dFormMainBase):
+ def __init__(self, parent=None, properties=None, *args, **kwargs):
+ self._baseClass = dFormMain
+ preClass = wx.PreFrame
+ dFormMainBase.__init__(self, preClass, parent, properties,
*args, **kwargs)
+
+
+class dFormMainParentMDI(wx.MDIParentFrame, dFormMainBase):
+ def __init__(self, parent=None, properties=None, *args, **kwargs):
+ self._baseClass = dFormMain
+ preClass = wx.PreMDIParentFrame
+ dFormMainBase.__init__(self, preClass, parent, properties,
*args, **kwargs)
+
+if dabo.settings.MDI:
+ dFormMain = dFormMainParentMDI
+else:
+ dFormMain = dFormMainSDI
+
+
if __name__ == "__main__":
import test
test.Test().runTest(dFormMain)
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev