dabo Commit
Revision 5996
Date: 2010-09-12 11:44:57 -0700 (Sun, 12 Sep 2010)
Author: Ed
Trac: http://trac.dabodev.com/changeset/5996
Changed:
U trunk/demo/samples/dHtmlBox.py
Log:
Improved the sample code for dHtmlBox to match the self-test code for the class.
Diff:
Modified: trunk/demo/samples/dHtmlBox.py
===================================================================
--- trunk/demo/samples/dHtmlBox.py 2010-09-12 18:19:19 UTC (rev 5995)
+++ trunk/demo/samples/dHtmlBox.py 2010-09-12 18:44:57 UTC (rev 5996)
@@ -10,50 +10,66 @@
def afterInit(self):
sz = self.Sizer = dabo.ui.dSizer("v")
sz.appendSpacer(25)
-
- hb = dabo.ui.dHtmlBox(self)
- sz.append(hb, 2, "x", border=10)
+
+ self.htmlbox = dabo.ui.dHtmlBox(self, Source=self.getPageData())
+ sz.append(self.htmlbox, 2, "x", border=10)
sz.appendSpacer(10)
-
- lbl = dabo.ui.dLabel(self, FontBold=True, FontItalic=True,
ForeColor="blue", WordWrap=True,
- Caption="Edit the HTML below, and then press
'TAB' to have the HTML updated in the dHtmlBox above.")
+
+ lbl = dabo.ui.dLabel(self, FontBold=True, FontItalic=True,
ForeColor="blue", WordWrap=True,
+ Caption="The HTML text below is the Source for
the dHtmlBox.\nEdit it to changed the displayed HTML.",
+ Alignment="Center")
+ lbl.FontSize -= 5
sz.append(lbl, halign="center")
sz.appendSpacer(2)
-
- eb = dabo.ui.dEditBox(self)
- sz.append1x(eb, border=10, borderSides=["left", "right"])
- sz.appendSpacer(5)
-
- eb.DataSource = hb
- eb.DataField = "Source"
- eb.Value = """<html>
-<body bgcolor="#ACAA60">
-<center>
- <table bgcolor="#AACCFF" width="100%%" cellspacing="0" cellpadding="0"
- border="1">
- <tr>
- <td align="center"><h1>dHtmlBox</h1></td>
- </tr>
- </table>
-</center>
-<p><b><font size="160%%" color="#FFFFFF">dHtmlBox</font></b> is a Dabo UI
widget that is designed to display html text.
-Be careful, though, because the widget doesn't support advanced functions like
-Javascript parsing.</p>
-<p>It's better to think of it as a way to display <b>rich text</b> using
-<font size="+1" color="#993300">HTML markup</font>, rather
-than a web browser replacement.</p>
-<p> </p>
-<div align="center"><img src="daboIcon.ico"></div>
+ eb = dabo.ui.dEditBox(self, DataSource=self.htmlbox,
DataField="Source")
+ eb.bindEvent(dEvents.KeyChar, self.textChangeHandler)
+ sz.append1x(eb)
+ sz.appendSpacer(2)
+ btn = dabo.ui.dButton(self, Caption="Reset",
OnHit=self.resetHTML)
+ sz.append(btn, halign="right", border=10, borderSides=["right",
"bottom"])
+ self.layout()
-<p align="center"><b><a href="http://dabodev.com">Dabo</a></b> is brought to
you by <b>Ed Leafe</b>, <b>Paul McNett</b>,
-and others in the open source community. Copyright © 2004-%s
-</p>
-</body>
-</html>
-""" % datetime.date.today().year
+ def textChangeHandler(self, evt):
+ dabo.ui.callAfter(evt.EventObject.flushValue)
+
+ def resetHTML(self, evt):
+ self.htmlbox.Source = self.getPageData()
+ self.update()
+
+
+ def getPageData(self):
+ return """<html>
+ <body bgcolor="#B0C4DE">
+ <center>
+ <table bgcolor="#8470FF" width="100%%" cellspacing="0"
cellpadding="0"
+ border="1">
+ <tr>
+ <td
align="center"><h1>dHtmlBox</h1></td>
+ </tr>
+ </table>
+ </center>
+ <p><b><font size="+2" color="#FFFFFF">dHtmlBox</font></b> is a
Dabo UI widget that is designed to display html text.
+ Be careful, though, because the widget doesn't support advanced
functions like
+ Javascript parsing.</p>
+ <p>It's better to think of it as a way to display <b>rich
text</b> using
+ <font size="+1" color="#993300">HTML markup</font>, rather
+ than a web browser replacement, although you <i>can</i> create
links that will open
+ in a web browser, like this: <a
href="http://wiki.dabodev.com">Dabo Wiki</a>.</p>
+
+ <p> </p>
+ <div align="center"><img src="daboIcon.ico"></div>
+
+ <p align="center"><b><a href="http://dabodev.com">Dabo</a></b>
is brought to you by <b>Ed Leafe</b>, <b>Paul McNett</b>,
+ and others in the open source community. Copyright ©
2004-%s
+ </p>
+ </body>
+ </html>
+ """ % datetime.date.today().year
+
+
category = "Controls.dHtmlBox"
overview = """
_______________________________________________
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]