]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/FancyText.py
1 # 11/5/2003 - Jeff Grimmett (grimmtooth@softhome.net)
3 # o Updated to wx namespace
5 # 11/25/2003 - Jeff Grimmett (grimmtooth@softhome.net)
7 # o Issues previously noted have evaporated.
8 # o Hoo boy, the doc string in the lib needs fixed :-)
10 # 12/02/2003 - Jeff Grimmett (grimmtooth@softhome.net)
12 # o Making the library's doc string acceptable for the overview rendered
13 # it unusable in the library's own test code, so I copied it over
14 # and massaged the XML into useful HTML.
18 import wx
.lib
.fancytext
as fancytext
20 #----------------------------------------------------------------------
22 test_str
= ('<font style="italic" family="swiss" color="red" weight="bold" >'
23 'some |<sup>23</sup> <angle/>text<sub>with <angle/> subscript</sub>'
24 '</font> some other text')
26 test_str2
= '<font family="swiss" color="dark green" size="40">big green text</font>'
29 class TestPanel(wx
.Panel
):
30 def __init__(self
, parent
):
31 wx
.Panel
.__init
__(self
, parent
, -1)
32 self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
)
34 def OnPaint(self
, evt
):
37 w
, h
= fancytext
.GetExtent(test_str
, dc
)
38 fancytext
.RenderToDC(test_str
, dc
, 20, 20)
40 fancytext
.RenderToDC(test_str2
, dc
, 20, 20 + h
+ 10)
43 #----------------------------------------------------------------------
45 def runTest(frame
, nb
, log
):
49 #----------------------------------------------------------------------
57 <h1>FancyText -- <i>methods for rendering XML specified text</i></h1>
59 <p>This module exports four main methods::
61 def GetExtent(str, dc=None, enclose=True)
62 def GetFullExtent(str, dc=None, enclose=True)
63 def RenderToBitmap(str, background=None, enclose=True)
64 def RenderToDC(str, dc, x, y, enclose=True)
67 In all cases, 'str' is an XML string. Note that start and end tags
68 are only required if *enclose* is set to False. In this case the
69 text should be wrapped in FancyText tags.
71 <p>In addition, the module exports one class::
73 class StaticFancyText(self, window, id, text, background, ...)
75 This class works similar to StaticText except it interprets its text
78 <p>The text can support<sup>superscripts</sup> and <sub>subscripts</sub>, text
79 in different <font size="+3">sizes</font>, <font color="blue">colors</font>,
80 <i>styles</i>, <b>weights</b> and
81 <font family="script">families</font>. It also supports a limited set of symbols,
82 currently <times/>, <infinity/>, <angle/> as well as greek letters in both
83 upper case (<Alpha/><Beta/>...<Omega/>) and lower case (<alpha/><beta/>...<omega/>).
93 if __name__
== '__main__':
96 run
.main(['', os
.path
.basename(sys
.argv
[0])])