dabo Commit
Revision 6667
Date: 2011-07-05 03:22:04 -0700 (Tue, 05 Jul 2011)
Author: Jacekk
Trac: http://trac.dabodev.com/changeset/6667
Changed:
U trunk/dabo/ui/uiwx/dPage.py
U trunk/dabo/ui/uiwx/dPageFrameMixin.py
Log:
Newly added the dPageFrame.UseSmartFocus property could improve ergonomics when
navigating between pages.
Diff:
Modified: trunk/dabo/ui/uiwx/dPage.py
===================================================================
--- trunk/dabo/ui/uiwx/dPage.py 2011-07-04 16:06:01 UTC (rev 6666)
+++ trunk/dabo/ui/uiwx/dPage.py 2011-07-05 10:22:04 UTC (rev 6667)
@@ -46,7 +46,7 @@
self.createItems()
self.itemsCreated = True
self.layout()
- self.unlockDisplay()
+ dabo.ui.callAfter(self.unlockDisplay)
def createItems(self):
@@ -81,10 +81,20 @@
def __onPageLeave(self, evt):
if hasattr(self, "Form"):
- if hasattr(self.Form, "activeControlValid"):
- self.Form.activeControlValid()
+ form = self.Form
+ if hasattr(form, "activeControlValid"):
+ form.activeControlValid()
+ def _saveLastActiveControl(self):
+ self._lastFocusedControl = self.Form.ActiveControl
+
+
+ def _restoreLastActiveControl(self):
+ if getattr(self, "_lastFocusedControl", None):
+ self.Form.ActiveControl = self._lastFocusedControl
+
+
def _getPagePosition(self):
"""Returns the position of this page within its parent."""
try:
Modified: trunk/dabo/ui/uiwx/dPageFrameMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPageFrameMixin.py 2011-07-04 16:06:01 UTC (rev
6666)
+++ trunk/dabo/ui/uiwx/dPageFrameMixin.py 2011-07-05 10:22:04 UTC (rev
6667)
@@ -15,6 +15,13 @@
class dPageFrameMixin(cm.dControlMixin):
"""Creates a container for an unlimited number of pages."""
+
+ def __init__(self, preClass, parent, properties=None,
attProperties=None, *args, **kwargs):
+ kwargs["style"] = self._extractKey((properties, kwargs),
"style", 0) | wx.CLIP_CHILDREN
+ super(dPageFrameMixin, self).__init__(preClass, parent,
properties=properties,
+ attProperties=attProperties, *args, **kwargs)
+
+
def _beforeInit(self, pre):
self._imageList = {}
self._pageSizerClass = dabo.ui.dSizer
@@ -36,6 +43,8 @@
evt.Veto()
else:
evt.Skip()
+ if oldPageNum >= 0 and self.PageCount > oldPageNum:
+ self.Pages[oldPageNum]._saveLastActiveControl()
self.raiseEvent(dEvents.PageChanging, oldPageNum=oldPageNum,
newPageNum=newPageNum)
@@ -77,7 +86,7 @@
return
self._lastPage = newPageNum
if oldPageNum is not None:
- if oldPageNum >=0:
+ if oldPageNum >= 0:
try:
oldPage = self.Pages[oldPageNum]
dabo.ui.callAfter(oldPage.raiseEvent,
dEvents.PageLeave)
@@ -90,6 +99,8 @@
dabo.ui.callAfter(newPage.raiseEvent, dEvents.PageEnter)
dabo.ui.callAfter(self.raiseEvent, dEvents.PageChanged,
oldPageNum=oldPageNum,
newPageNum=newPageNum)
+ if self.UseSmartFocus:
+ newPage._restoreLastActiveControl()
# Image-handling function
@@ -232,7 +243,7 @@
self.Parent.lockDisplay()
pos = oldPgOrPos
if isinstance(oldPgOrPos, int):
- if oldPgOrPos > self.PageCount-1:
+ if oldPgOrPos > self.PageCount - 1:
return False
pg = self.Pages[oldPgOrPos]
else:
@@ -240,7 +251,7 @@
pos = self.Pages.index(pg)
# Make sure that the new position is valid
newPos = max(0, newPos)
- newPos = min(self.PageCount-1, newPos)
+ newPos = min(self.PageCount - 1, newPos)
if newPos == pos:
# No change
return
@@ -323,10 +334,10 @@
for i in range(pageCount, val):
pg = self.appendPage(pageClass)
if not pg.Caption:
- pg.Caption = _("Page %s") %
(i+1,)
+ pg.Caption = _("Page %s") % (i
+ 1,)
elif val < pageCount:
for i in range(pageCount, val, -1):
- self.DeletePage(i-1)
+ self.DeletePage(i - 1)
else:
self._properties["PageCount"] = val
@@ -417,20 +428,27 @@
self._updateInactivePages = val
+ def _getUseSmartFocus(self):
+ return getattr(self, "_useSmartFocus", False)
+
+ def _setUseSmartFocus(self, val):
+ self._useSmartFocus = val
+
+
# Property definitions:
PageClass = property(_getPageClass, _setPageClass, None,
_("""Specifies the class of control to use for pages by
default. (classRef)
This really only applies when using the PageCount
property to set the
number of pages. If you instead use AddPage() you still
need to send
- an instance as usual. Class must descend from a dabo
base class.""") )
+ an instance as usual. Class must descend from a dabo
base class."""))
PageCount = property(_getPageCount, _setPageCount, None,
_("""Specifies the number of pages in the pageframe.
(int)
When using this to increase the number of pages,
PageClass
- will be queried as the object to use as the page
object.""") )
+ will be queried as the object to use as the page
object."""))
Pages = property(_getPages, None, None,
- _("Returns a list of the contained pages. (list)") )
+ _("Returns a list of the contained pages. (list)"))
PageSizerClass = property(_getPageSizerClass, _setPageSizerClass, None,
_("""Default sizer class for pages added automatically
to this control. Set
@@ -438,25 +456,30 @@
pages. (dSizer or None)"""))
SelectedPage = property(_getSelectedPage, _setSelectedPage, None,
- _("References the current frontmost page. (dPage)") )
+ _("References the current frontmost page. (dPage)"))
SelectedPageNumber = property(_getSelectedPageNumber,
_setSelectedPageNumber,
None,
- _("Returns the index of the current frontmost page.
(int)") )
+ _("Returns the index of the current frontmost page.
(int)"))
TabPosition = property(_getTabPosition, _setTabPosition, None,
_("""Specifies where the page tabs are located. (int)
Top (default)
Left
Right
- Bottom""") )
+ Bottom"""))
UpdateInactivePages = property(_getUpdateInactivePages,
_setUpdateInactivePages, None,
_("""Determines if the inactive pages are updated too.
(bool)
Setting it to False can significantly improve update
performance
of multipage forms. Default=True."""))
+ UseSmartFocus = property(_getUseSmartFocus, _setUseSmartFocus, None,
+ _("""Determines if focus has to be restored to the last
active
+ control on page when it become selected. (bool)
Default=False.
+ """))
+
DynamicPageClass = makeDynamicProperty(PageClass)
DynamicPageCount = makeDynamicProperty(PageCount)
DynamicSelectedPage = makeDynamicProperty(SelectedPage)
_______________________________________________
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]