dabo Commit
Revision 4838
Date: 2008-12-15 12:39:25 -0800 (Mon, 15 Dec 2008)
Author: Paul
Trac: http://trac.dabodev.com/dabo/changeset/4838
Changed:
U trunk/dabo/lib/datanav/Form.py
U trunk/dabo/ui/uiwx/dFormMixin.py
U trunk/dabo/ui/uiwx/dToolBar.py
Log:
Asking for the values of the properties ToolBar and StatusBar resulted in the
side-effect of creating the ToolBar or StatusBar if they weren't already
created, which it really shouldn't do. Fixed to create ToolBar and
StatusBar at the appropriate time, if not already created by user
code.
Setting ToolBar had the side-effect of creating a reference to the Form
property, which isn't necessary because Form is derived from Parent, and
Parent gets set when the toolbar is constructed. Removed the Form property
from dToolBar.py (so now it comes from dPemMixinBase like all other
controls).
StatusBar wasn't a settable property! Fixed.
Diff:
Modified: trunk/dabo/lib/datanav/Form.py
===================================================================
--- trunk/dabo/lib/datanav/Form.py 2008-12-15 20:35:19 UTC (rev 4837)
+++ trunk/dabo/lib/datanav/Form.py 2008-12-15 20:39:25 UTC (rev 4838)
@@ -64,7 +64,7 @@
def setupToolBar(self):
- tb = self.ToolBar
+ tb = self.ToolBar = dabo.ui.dToolBar(self)
if tb.Children:
# It's already been set up
return
Modified: trunk/dabo/ui/uiwx/dFormMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dFormMixin.py 2008-12-15 20:35:19 UTC (rev 4837)
+++ trunk/dabo/ui/uiwx/dFormMixin.py 2008-12-15 20:39:25 UTC (rev 4838)
@@ -177,13 +177,25 @@
def __onActivate(self, evt):
# If the ShowStatusBar property was set to True, this will
create it
- sb = self.StatusBar
+ self._createStatusBar()
# If the ShowToolBar property was set to True, this will create
it
- tb = self.ToolBar
-
+ self._createToolBar()
+
if self.Application is not None:
if self.Application.Platform != "Win":
self.Application.ActiveForm = self
+
+
+ def _createToolBar(self):
+ if self.ShowToolBar and self.ToolBar is None:
+ self.ToolBar = dabo.ui.dToolBar(self)
+
+
+ def _createStatusBar(self):
+ if (self.ShowStatusBar
+ and self.StatusBar is None
+ and (sys.platform.startswith("darwin") or not
isinstance(self, wx.MDIChildFrame))):
+ self.StatusBar = dabo.ui.dStatusBar(self)
def __onDeactivate(self, evt):
@@ -909,22 +921,16 @@
def _getStatusBar(self):
try:
- ret = self.GetStatusBar()
+ return self.GetStatusBar()
except (TypeError, AttributeError):
# pkm: My client got a TypeError from the wx layer,
perhaps because the
# window is a dialog and not a form, but I can't
reproduce on my end.
# Just return None immediately if this happens
again.
return None
- if (ret is None
- and (sys.platform.startswith("darwin") or not
isinstance(self, wx.MDIChildFrame))
- and self.ShowStatusBar):
- ret = dabo.ui.dStatusBar(self)
- self.SetStatusBar(ret)
- else:
- ret = None
- return ret
-
+ def _setStatusBar(self, val):
+ self.SetStatusBar(val)
+
def _getStatusText(self):
ret = ""
if sys.platform.startswith("win") and isinstance(self,
wx.MDIChildFrame):
@@ -992,21 +998,26 @@
def _getToolBar(self):
- if hasattr(self, "GetToolBar"):
- ret = self.GetToolBar()
- if ret is None and self.ShowToolBar:
- ret = dabo.ui.dToolBar(self)
- self.ToolBar = ret
- else:
- ret = None
- return ret
+ try:
+ return self.GetToolBar()
+ except AttributeError:
+ # We are probably a dialog
+ return None
+ except TypeError:
+ # May be too early in control instantiation: I'm seeing
this
+ # in my error logs for my app, but can't reproduce on
my end:
+ # Traceback (most recent call last):
+ # File "dabo\ui\uiwx\dFormMixin.pyc", line 180, in
__onWxActivate
+ # File "dabo\ui\uiwx\dPemMixin.pyc", line 942, in
raiseEvent
+ # File "dabo\lib\eventMixin.pyc", line 92, in
raiseEvent
+ # File "dabo\ui\uiwx\dFormMixin.pyc", line 191, in
__onActivate
+ # File "dabo\ui\uiwx\dFormMixin.pyc", line 969, in
_getToolBar
+ # File "wx\_windows.pyc", line 578, in GetToolBar
+ #<type 'exceptions.TypeError'>: in method
'Frame_GetToolBar', expected argument 1 of type 'wxFrame const *'
+ return None
def _setToolBar(self, val):
self.SetToolBar(val)
- if val is not None:
- # the wx toolbar doesn't otherwise know what form it is
attached to:
- val.Form = self
-
def _getWindowState(self):
try:
@@ -1140,7 +1151,7 @@
ShowToolBar = property(_getShowToolBar, _setShowToolBar, None,
_("Specifies whether the Tool bar gets automatically
created."))
- StatusBar = property(_getStatusBar, None, None,
+ StatusBar = property(_getStatusBar, _setStatusBar, None,
_("Status bar for this form. (dStatusBar)"))
StatusText = property(_getStatusText, _setStatusText, None,
Modified: trunk/dabo/ui/uiwx/dToolBar.py
===================================================================
--- trunk/dabo/ui/uiwx/dToolBar.py 2008-12-15 20:35:19 UTC (rev 4837)
+++ trunk/dabo/ui/uiwx/dToolBar.py 2008-12-15 20:39:25 UTC (rev 4838)
@@ -354,17 +354,6 @@
self._addWindowStyleFlag(wx.TB_DOCKABLE)
- def _getForm(self):
- try:
- v = self._form
- except AttributeError:
- v = self._form = None
- return v
-
- def _setForm(self, val):
- self._form = val
-
-
def _getMaxHt(self):
try:
v = self._maxHt
@@ -427,9 +416,6 @@
Currently, this only seems to work on Linux, and can't
be changed after
instantiation. Default is True."""))
- Form = property(_getForm, _setForm, None,
- _("Specifies the form that we are a member of."))
-
MaxHeight = property(_getMaxHt, _setMaxHt, None,
_("""Specifies the maximum height of added buttons. (int)
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]