dabo Commit
Revision 3142
Date: 2007-05-27 08:33:46 -0700 (Sun, 27 May 2007)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/3142
Changed:
U trunk/dabo/ui/dialogs/Wizard.py
U trunk/dabo/ui/dialogs/WizardPage.py
Log:
Wizard:
Changed the 'Image' property to 'Picture' instead to be more consistent
with other Dabo classes.
Deprecated the use of 'image' as a parameter. Use the Picture property
instead.
If any page has a non-empty Picture property, that is displayed instead
of the default image for the wizard when that page is shown.
Changed the default Picture to 'daboIcon096'
Changed __init__() so that the BorderResizable and
ShowMax/Min/CloseButton properties can be overridden from their default of
False if explicitly passed.
Changed the demo to illustrate changing the Picture for a given page.
Wizard Page:
Changed the 'Title' property to 'Caption' in order to be more
consistent with the rest of the framework.
Added the 'Picture' property. Specifying a picture path here will
display that image when the page is shown instead of the default for the wizard.
Diff:
Modified: trunk/dabo/ui/dialogs/Wizard.py
===================================================================
--- trunk/dabo/ui/dialogs/Wizard.py 2007-05-27 15:22:29 UTC (rev 3141)
+++ trunk/dabo/ui/dialogs/Wizard.py 2007-05-27 15:33:46 UTC (rev 3142)
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+import warnings
import dabo
dabo.ui.loadUI("wx")
from dabo.dLocalize import _
@@ -16,13 +17,16 @@
def __init__(self, parent=None, properties=None, *args, **kwargs):
pgs = self._extractKey(kwargs, "Pages")
- self.iconName = self._extractKey(kwargs, "image")
- kwargs["BorderResizable"] = False
- kwargs["ShowMaxButton"] = False
- kwargs["ShowMinButton"] = False
- kwargs["ShowCloseButton"] = False
-# kwargs["ShowStatusBar"] = False
-
+ # Backwards compatibility; deprecated in 0.9
+ img = self._extractKey(kwargs, "image")
+ if img:
+ warnmsg = _("Deprecated parameter 'image' used in
wizard. Use the 'Picture' property instead.")
+ warnings.warn(warnmsg, DeprecationWarning, stacklevel=2)
+ kwargs["Picture"] = img
+ kwargs["BorderResizable"] = kwargs.get("BorderResizable", False)
+ kwargs["ShowMaxButton"] = kwargs.get("ShowMaxButton", False)
+ kwargs["ShowMinButton"] = kwargs.get("ShowMinButton", False)
+ kwargs["ShowCloseButton"] = kwargs.get("ShowCloseButton", False)
super(Wizard, self).__init__(parent=parent,
properties=properties, *args, **kwargs)
@@ -68,9 +72,10 @@
# Add a top border
mpsz.appendSpacer(mpsz.DefaultBorder)
- if not self.iconName:
- self.iconName = "empty"
- self.wizardIcon = dabo.ui.dBitmap(mp, Picture=self.iconName)
+ if not self.Picture:
+ self.Picture = "daboIcon096"
+ self.wizardIcon = dabo.ui.dImage(mp, ScaleMode="Clip",
+ Picture=self.Picture)
hsz = dabo.ui.dSizer("h")
hsz.DefaultSpacing = 20
hsz.append(self.wizardIcon, 0)
@@ -165,28 +170,31 @@
def append(self, pg):
if isinstance(pg, (list, tuple)):
+ ret = []
for p in pg:
- self.append(p)
+ ret.append(self.append(p))
else:
- page = pg(self.pagePanel)
- page.wizard = self
- page.Size = self.pagePanel.Size
- self._pages.append(page)
- page.Visible = False
+ return self.insert(len(self._pages), pg)
def insert(self, pos, pg):
if isinstance(pg, (list, tuple)):
pg.reverse()
+ ret = []
for p in pg:
- self.insert(pos, p)
+ ret.append(self.insert(pos, p))
else:
- page = pg(self.pagePanel)
- page.Size = self.pagePanel.Size
- self._pages.insert(pos, page)
- page.Visible = False
-
+ # Give subclasses a chance to override
+ page = self._insertWizardPageOverride(pos, pg)
+ if page is None:
+ page = pg(self.pagePanel)
+ page.Size = self.pagePanel.Size
+ self._pages.insert(pos, page)
+ page.Visible = False
+ return page
+ def _insertWizardPageOverride(self, pos, pg): pass
+
def getPageByClass(self, pgClass):
"""Returns the first page that is an instance of the passed
class"""
try:
@@ -222,8 +230,12 @@
if idx == (self.PageCount-1):
cap = _("Finish")
self.btnNext.Caption = cap
+ if page.Picture is not None:
+ self.wizardIcon.Picture = page.Picture
+ else:
+ self.wizardIcon.Picture = self.Picture
else:
- self._pages[idx].Visible = False
+ page.Visible = False
self.layout()
@@ -252,17 +264,9 @@
# Property methods
- def _getImage(self):
- return self.wizardIcon.Picture
- def _setImage(self, val):
- self.wizardIcon.Picture = val
- self.layout()
-
- def _getPageCount(self):
- return len(self._pages)
-
def _getCurrPage(self):
return self._currentPage
+
def _setCurrPage(self, val):
if self.PageCount == 0:
self.showBlankPage()
@@ -288,15 +292,38 @@
self.showPage()
- Image = property(_getImage, _setImage, None,
- _("Sets the visible icon for the wizard") )
+ def _getPicture(self):
+ try:
+ ret = self.wizardIcon.Picture
+ except AttributeError:
+ ret = ""
+ return ret
+
+ def _setPicture(self, val):
+ if self._constructed():
+ try:
+ self.wizardIcon.Picture = val
+ except AttributeError:
+ # wizard icon hasn't been constructed yet.
+ dabo.ui.setAfter(self, "Picture", val)
+ self.layout()
+ else:
+ self._properties["Picture"] = val
+
- PageCount = property(_getPageCount, None, None,
- _("Number of pages in this wizard (int)") )
-
+ def _getPageCount(self):
+ return len(self._pages)
+
+
CurrentPage = property(_getCurrPage, _setCurrPage, None,
_("Index of the current page in the wizard
(WizardPage)") )
+ PageCount = property(_getPageCount, None, None,
+ _("Number of pages in this wizard (int)") )
+
+ Picture = property(_getPicture, _setPicture, None,
+ _("Sets the visible icon for the wizard. (str/path)") )
+
if __name__ == "__main__":
@@ -346,6 +373,7 @@
class WizPageFour(WizardPage):
def createBody(self):
self.Title = _("This is the fourth page")
+ self.Picture = "cards/small/s1.png"
lbl = dabo.ui.dLabel(self, Caption=_(
"""Did the skipping work OK?
""") )
@@ -356,6 +384,10 @@
self.Sizer.appendSpacer(16)
self.Sizer.append(self.txt, alignment="center")
self.Sizer.append(lbl, alignment="center")
+ lbl = dabo.ui.dLabel(self, Caption=_(
+ "Also note that this page has a
different icon!") )
+ self.Sizer.appendSpacer(5)
+ self.Sizer.append(lbl, alignment="center")
def prevPage(self):
Modified: trunk/dabo/ui/dialogs/WizardPage.py
===================================================================
--- trunk/dabo/ui/dialogs/WizardPage.py 2007-05-27 15:22:29 UTC (rev 3141)
+++ trunk/dabo/ui/dialogs/WizardPage.py 2007-05-27 15:33:46 UTC (rev 3142)
@@ -10,30 +10,29 @@
class WizardPage(dabo.ui.dScrollPanel):
def __init__(self, parent, properties=None, *args, **kwargs):
self._baseClass = WizardPage
- self._titleCaption = self._extractKey(kwargs, "Title")
+ self._titleLabel = None
+ self._caption = _("Wizard Page")
+ self._titleFontFace = ""
+ self._titleFontSize = 18
+ self._picture = None
super(WizardPage, self).__init__(parent=parent,
properties=properties, *args, **kwargs)
self._wizard = None
self._nextPage = self._prevPage = None
- self._title = None
- self._titleFontFace = self.FontFace
- self._titleFontSize = 18
self.setup()
self.layout()
def setup(self):
self.makeSizer()
- if self.Title is None:
- self.Title = ""
- self._title = dabo.ui.dLabel(self, Caption=self.Title,
FontSize=self.TitleSize,
+ self._titleLabel = dabo.ui.dLabel(self, Caption=self.Caption,
FontSize=self.TitleSize,
FontFace=self.TitleFace)
ln = dabo.ui.dLine(self)
self.Sizer.prepend(ln, "x")
self.Sizer.prependSpacer(16)
- self.Sizer.prepend(self._title, alignment="center")
+ self.Sizer.prepend(self._titleLabel, alignment="center")
self._createBody()
@@ -102,23 +101,40 @@
# Property definitions.
- def _getTitle(self):
- return self._titleCaption
+ def _getCaption(self):
+ return self._caption
- def _setTitle(self, val):
- self._titleCaption = val
- if self._title:
- self._title.Caption = val
- self.layout()
+ def _setCaption(self, val):
+ if self._constructed():
+ self._caption = val
+ if self._titleLabel:
+ self._titleLabel.Caption = val
+ self.layout()
+ else:
+ self._properties["Caption"] = val
+ def _getPicture(self):
+ return self._picture
+
+ def _setPicture(self, val):
+ if self._constructed():
+ self._picture = val
+ else:
+ self._properties["Picture"] = val
+
+
def _getTitleFace(self):
- return self._titleFontFace
+ try:
+ return self._titleFontFace
+ except AttributeError:
+ self._titleFontFace = self.FontFace
+ return self._titleFontFace
def _setTitleFace(self, val):
self._titleFontFace = val
- if self._title:
- self._title.FontFace = val
+ if self._titleLabel:
+ self._titleLabel.FontFace = val
self.layout()
@@ -127,8 +143,8 @@
def _setTitleSize(self, val):
self._titleFontSize = val
- if self._title:
- self._title.FontSize = val
+ if self._titleLabel:
+ self._titleLabel.FontSize = val
self.layout()
@@ -143,9 +159,13 @@
- Title = property(_getTitle, _setTitle, None,
- _("Displays a title at the top of the page. (string)")
)
-
+ Caption = property(_getCaption, _setCaption, None,
+ _("The text that appears as the title of the page
(str)"))
+
+ Picture = property(_getPicture, _setPicture, None,
+ _("""Normally None, but you can set it to some other
image to have the wizard display
+ a different picture for this page (None or image
path)"""))
+
TitleFace = property(_getTitleFace, _setTitleFace, None,
_("Name of the font face used for the Title.
(string)") )
_______________________________________________
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/dabo-dev/[EMAIL PROTECTED]