]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/FancyText.py
3 import wx
.lib
.fancytext
as fancytext
5 #----------------------------------------------------------------------
7 test_str
= ('<font style="italic" family="swiss" color="red" weight="bold" >'
8 'some |<sup>23</sup> <angle/>text<sub>with <angle/> subscript</sub>'
9 '</font> some other text')
11 test_str2
= '<font family="swiss" color="dark green" size="40">big green text</font>'
14 class TestPanel(wx
.Panel
):
15 def __init__(self
, parent
):
16 wx
.Panel
.__init
__(self
, parent
, -1)
17 self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
)
19 def OnPaint(self
, evt
):
22 w
, h
= fancytext
.GetExtent(test_str
, dc
)
23 fancytext
.RenderToDC(test_str
, dc
, 20, 20)
25 fancytext
.RenderToDC(test_str2
, dc
, 20, 20 + h
+ 10)
28 #----------------------------------------------------------------------
30 def runTest(frame
, nb
, log
):
34 #----------------------------------------------------------------------
42 <h1>FancyText -- <i>methods for rendering XML specified text</i></h1>
44 <p>This module exports four main methods::
46 def GetExtent(str, dc=None, enclose=True)
47 def GetFullExtent(str, dc=None, enclose=True)
48 def RenderToBitmap(str, background=None, enclose=True)
49 def RenderToDC(str, dc, x, y, enclose=True)
52 In all cases, 'str' is an XML string. Note that start and end tags
53 are only required if *enclose* is set to False. In this case the
54 text should be wrapped in FancyText tags.
56 <p>In addition, the module exports one class::
58 class StaticFancyText(self, window, id, text, background, ...)
60 This class works similar to StaticText except it interprets its text
63 <p>The text can support<sup>superscripts</sup> and <sub>subscripts</sub>, text
64 in different <font size="+3">sizes</font>, <font color="blue">colors</font>,
65 <i>styles</i>, <b>weights</b> and
66 <font family="script">families</font>. It also supports a limited set of symbols,
67 currently <times/>, <infinity/>, <angle/> as well as greek letters in both
68 upper case (<Alpha/><Beta/>...<Omega/>) and lower case (<alpha/><beta/>...<omega/>).
78 if __name__
== '__main__':
81 run
.main(['', os
.path
.basename(sys
.argv
[0])])