dabo Commit
Revision 4405
Date: 2008-08-13 14:03:25 -0700 (Wed, 13 Aug 2008)
Author: Nate
Trac: http://svn.dabodev.com/trac/dabo/changeset/4405
Changed:
U branches/Nate/dabo/dEvents.py
U branches/Nate/dabo/ui/uiwx/__init__.py
U branches/Nate/dabo/ui/uiwx/dPageFrame.py
Log:
Ok, so until we can get a naming convention straight, I am calling it
dAdvancedPageFrame. Restored the original dPageFrame, and changed dEvents.py
and __init__.py to work with both.
Added a ShowMenuOnSingleTabs property to the dAdvancedPageFrame. If set to
False, when there is a single tab the menu with the tab thumbs, nav buttons,
and close button will be hidden. If another page is added, it will be show
again. When set to True, the menu is shown all the time.
Diff:
Modified: branches/Nate/dabo/dEvents.py
===================================================================
--- branches/Nate/dabo/dEvents.py 2008-08-13 19:44:54 UTC (rev 4404)
+++ branches/Nate/dabo/dEvents.py 2008-08-13 21:03:25 UTC (rev 4405)
@@ -455,7 +455,7 @@
"""Occurs when a page in a pageframe-like control changes"""
def appliesToClass(eventClass, objectClass):
return issubclass(objectClass, (dabo.ui.dPageFrame,
dabo.ui.dPageList,
- dabo.ui.dPageSelect, dabo.ui.dPageFrameNoTabs))
+ dabo.ui.dPageSelect, dabo.ui.dPageFrameNoTabs,
dabo.ui.dAdvancedPageFrame))
appliesToClass = classmethod(appliesToClass)
@@ -463,21 +463,21 @@
"""Occurs when the current page in a pageframe-like control is about to
change"""
def appliesToClass(eventClass, objectClass):
return issubclass(objectClass, (dabo.ui.dPageFrame,
dabo.ui.dPageList,
- dabo.ui.dPageSelect, dabo.ui.dPageFrameNoTabs))
+ dabo.ui.dPageSelect, dabo.ui.dPageFrameNoTabs,
dabo.ui.dAdvancedPageFrame))
appliesToClass = classmethod(appliesToClass)
class PageClosed(dEvent):
"""Occurs when a page in a dPageFrame control is closed"""
def appliesToClass(eventClass, objectClass):
- return issubclass(objectClass, dabo.ui.dPageFrame)
+ return issubclass(objectClass, dabo.ui.dAdvancedPageFrame)
appliesToClass = classmethod(appliesToClass)
class PageClosing(dEvent):
"""Occurs when a page in a dPageFrame control is about to close"""
def appliesToClass(eventClass, objectClass):
- return issubclass(objectClass, dabo.ui.dPageFrame)
+ return issubclass(objectClass, dabo.ui.dAdvancedPageFrame)
appliesToClass = classmethod(appliesToClass)
Modified: branches/Nate/dabo/ui/uiwx/__init__.py
===================================================================
--- branches/Nate/dabo/ui/uiwx/__init__.py 2008-08-13 19:44:54 UTC (rev
4404)
+++ branches/Nate/dabo/ui/uiwx/__init__.py 2008-08-13 21:03:25 UTC (rev
4405)
@@ -124,6 +124,7 @@
from dPanel import dPanel
from dPanel import dScrollPanel
from dPageFrame import dPageFrame
+from dPageFrame import dAdvancedPageFrame
from dPageFrame import dPageList
from dPageFrame import dPageSelect
from dPageFrameNoTabs import dPageFrameNoTabs
Modified: branches/Nate/dabo/ui/uiwx/dPageFrame.py
===================================================================
--- branches/Nate/dabo/ui/uiwx/dPageFrame.py 2008-08-13 19:44:54 UTC (rev
4404)
+++ branches/Nate/dabo/ui/uiwx/dPageFrame.py 2008-08-13 21:03:25 UTC (rev
4405)
@@ -21,8 +21,29 @@
""" Create a read-only property. """
return property(lambda self: value)
+class dPageFrame(dPageFrameMixin, wx.Notebook):
+ """Creates a pageframe, which can contain an unlimited number of pages,
+ each of which should be a subclass/instance of the dPage class.
+ """
+ _evtPageChanged = readonly(wx.EVT_NOTEBOOK_PAGE_CHANGED)
+ _evtPageChanging = readonly(wx.EVT_NOTEBOOK_PAGE_CHANGING)
+ _tabposBottom = readonly(wx.NB_BOTTOM)
+ _tabposRight = readonly(wx.NB_RIGHT)
+ _tabposLeft = readonly(wx.NB_LEFT)
+
+ def __init__(self, parent, properties=None, attProperties=None, *args,
**kwargs):
+ self._baseClass = dPageFrame
+ preClass = wx.PreNotebook
+
+ dPageFrameMixin.__init__(self, preClass, parent, properties,
attProperties, *args, **kwargs)
+
+ def _afterInit(self):
+ if sys.platform[:3] == "win":
+ ## This keeps Pages from being ugly on Windows:
+ self.SetBackgroundColour(self.GetBackgroundColour())
+ super(dPageFrame, self)._afterInit()
-class dPageFrame(dPageFrameMixin, fnb.FlatNotebook):
+class dAdvancedPageFrame(dPageFrameMixin, fnb.FlatNotebook):
"""Creates a pageframe, which can contain an unlimited number of pages,
each of which should be a subclass/instance of the dPage class.
"""
@@ -31,13 +52,15 @@
_tabposBottom = readonly(fnb.FNB_BOTTOM)
def __init__(self, parent, properties=None, attProperties=None, *args,
**kwargs):
- self._baseClass = dPageFrame
+ self._baseClass = dAdvancedPageFrame
preClass = fnb.FlatNotebook
+ self._showMenuOnSingleTab = True
+
dPageFrameMixin.__init__(self, preClass, parent, properties,
attProperties, *args, **kwargs)
def _initEvents(self):
- super(dPageFrame, self)._initEvents()
+ super(dAdvancedPageFrame, self)._initEvents()
self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CLOSING,
self.__onPageClosing)
self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CLOSED, self.__onPageClosed)
self.Bind(fnb.EVT_FLATNOTEBOOK_PAGE_CONTEXT_MENU,
self.__onPageContextMenu)
@@ -46,7 +69,7 @@
if sys.platform[:3] == "win":
## This keeps Pages from being ugly on Windows:
self.SetBackgroundColour(self.GetBackgroundColour())
- super(dPageFrame, self)._afterInit()
+ super(dAdvancedPageFrame, self)._afterInit()
def __onPageClosing(self, evt):
"""The page has not yet been closed, so we can veto it if
conditions call for it."""
@@ -72,6 +95,18 @@
self.GetPage(self.GetSelection()).raiseEvent(dEvents.PageContextMenu)
#Property getters and setters
+ def _getShowMenuOnSingleTab(self):
+ return self._showMenuOnSingleTab
+
+ def _setShowMenuOnSingleTab(self, val):
+ val = bool(val)
+ if val:
+ self._delWindowStyleFlag(fnb.FNB_HIDE_ON_SINGLE_TAB)
+ else:
+ self._addWindowStyleFlag(fnb.FNB_HIDE_ON_SINGLE_TAB)
+ self._showMenuOnSingleTab = val
+
+
def _getTabPosition(self):
if self._hasWindowStyleFlag(self._tabposBottom):
return "Bottom"
@@ -90,6 +125,9 @@
raise ValueError, (_("The only possible values are
'Top' and 'Bottom'"))
#Property definitions
+ ShowMenuOnSingleTab = property(_getShowMenuOnSingleTab,
_setShowMenuOnSingleTab, None,
+ _("Specifies whether the tab thumbs and nav buttons are
shown when there is a single tab. (bool) (Default=True)"))
+
TabPosition = property(_getTabPosition, _setTabPosition, None,
_("""Specifies where the page tabs are located.
(string)
Top (default)
@@ -269,21 +307,21 @@
def onPageChanged(self, evt):
print "Page number changed from %s to %s" % (evt.oldPageNum,
evt.newPageNum)
-class _dPageFrame_test(TestMixin, dPageFrame):
+class _dAdvancedPageFrame_test(TestMixin, dAdvancedPageFrame):
def initProperties(self):
self.Width = 400
self.Height = 175
self.TabPosition = random.choice(("Top", "Bottom"))
-
+class _dPageFrame_test(TestMixin, dPageFrame): pass
class _dPageList_test(TestMixin, dPageList): pass
class _dPageSelect_test(TestMixin, dPageSelect): pass
class _dDockTabs_test(TestMixin, dDockTabs): pass
-
if __name__ == "__main__":
import test
test.Test().runTest(_dPageFrame_test)
test.Test().runTest(_dPageList_test)
test.Test().runTest(_dPageSelect_test)
+ test.Test().runTest(_dAdvancedPageFrame_test)
test.Test().runTest(_dDockTabs_test)
_______________________________________________
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]