X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1b62f00d8e3ec5437ab780cb3d73d299cc61e20c..156194e1d525407e90c21552f8f7aa05756e0ddc:/wxPython/demo/FancyText.py diff --git a/wxPython/demo/FancyText.py b/wxPython/demo/FancyText.py index edda6ce178..8b08afe393 100644 --- a/wxPython/demo/FancyText.py +++ b/wxPython/demo/FancyText.py @@ -1,6 +1,21 @@ - -from wxPython.wx import * -from wxPython.lib import fancytext +# 11/5/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated to wx namespace +# +# 11/25/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Issues previously noted have evaporated. +# o Hoo boy, the doc string in the lib needs fixed :-) +# +# 12/02/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Making the library's doc string acceptable for the overview rendered +# it unusable in the library's own test code, so I copied it over +# and massaged the XML into useful HTML. +# + +import wx +import wx.lib.fancytext as fancytext #---------------------------------------------------------------------- @@ -11,19 +26,18 @@ test_str = ('' test_str2 = 'big green text' -class TestPanel(wxPanel): +class TestPanel(wx.Panel): def __init__(self, parent): - wxPanel.__init__(self, parent, -1) - EVT_PAINT(self, self.OnPaint) - + wx.Panel.__init__(self, parent, -1) + self.Bind(wx.EVT_PAINT, self.OnPaint) def OnPaint(self, evt): - dc = wxPaintDC(self) + dc = wx.PaintDC(self) - sz = fancytext.getExtent(test_str, dc) - fancytext.renderToDC(test_str, dc, 20, 20) + w, h = fancytext.GetExtent(test_str, dc) + fancytext.RenderToDC(test_str, dc, 20, 20) - fancytext.renderToDC(test_str2, dc, 20, 20 + sz.height + 10) + fancytext.RenderToDC(test_str2, dc, 20, 20 + h + 10) #---------------------------------------------------------------------- @@ -36,6 +50,48 @@ def runTest(frame, nb, log): -import string -overview = string.replace(fancytext.__doc__, "<", "<") +overview = \ +""" + + +

FancyText -- methods for rendering XML specified text

+ +

This module exports four main methods:: +

+    def GetExtent(str, dc=None, enclose=True)
+    def GetFullExtent(str, dc=None, enclose=True)
+    def RenderToBitmap(str, background=None, enclose=True)
+    def RenderToDC(str, dc, x, y, enclose=True)
+
+ +In all cases, 'str' is an XML string. Note that start and end tags +are only required if *enclose* is set to False. In this case the +text should be wrapped in FancyText tags. + +

In addition, the module exports one class:: +

+    class StaticFancyText(self, window, id, text, background, ...)
+
+This class works similar to StaticText except it interprets its text +as FancyText. + +

The text can supportsuperscripts and subscripts, text +in different sizes, colors, +styles, weights and +families. It also supports a limited set of symbols, +currently , , as well as greek letters in both +upper case (...) and lower case (...). + + +The End + + +""" + + + +if __name__ == '__main__': + import sys,os + import run + run.main(['', os.path.basename(sys.argv[0])])