]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/FancyText.py
Fixed typo
[wxWidgets.git] / wxPython / demo / FancyText.py
CommitLineData
8fa876ca
RD
1
2import wx
3import wx.lib.fancytext as fancytext
1b62f00d
RD
4
5#----------------------------------------------------------------------
6
7test_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')
10
11test_str2 = '<font family="swiss" color="dark green" size="40">big green text</font>'
12
13
8fa876ca 14class TestPanel(wx.Panel):
1b62f00d 15 def __init__(self, parent):
8fa876ca
RD
16 wx.Panel.__init__(self, parent, -1)
17 self.Bind(wx.EVT_PAINT, self.OnPaint)
1b62f00d
RD
18
19 def OnPaint(self, evt):
8fa876ca 20 dc = wx.PaintDC(self)
1b62f00d 21
d14a1e28
RD
22 w, h = fancytext.GetExtent(test_str, dc)
23 fancytext.RenderToDC(test_str, dc, 20, 20)
1b62f00d 24
d14a1e28 25 fancytext.RenderToDC(test_str2, dc, 20, 20 + h + 10)
1b62f00d
RD
26
27
28#----------------------------------------------------------------------
29
30def runTest(frame, nb, log):
31 win = TestPanel(nb)
32 return win
33
34#----------------------------------------------------------------------
35
36
37
8fa876ca
RD
38overview = \
39"""
40<html>
41<body>
42<h1>FancyText -- <i>methods for rendering XML specified text</i></h1>
43
44<p>This module exports four main methods::
45<pre>
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)
50</pre>
51
52In all cases, 'str' is an XML string. Note that start and end tags
53are only required if *enclose* is set to False. In this case the
54text should be wrapped in FancyText tags.
55
56<p>In addition, the module exports one class::
57<pre>
58 class StaticFancyText(self, window, id, text, background, ...)
59</pre>
60This class works similar to StaticText except it interprets its text
61as FancyText.
62
63<p>The text can support<sup>superscripts</sup> and <sub>subscripts</sub>, text
64in 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,
67currently <times/>, <infinity/>, <angle/> as well as greek letters in both
68upper case (<Alpha/><Beta/>...<Omega/>) and lower case (<alpha/><beta/>...<omega/>).
69
70</font></font>
71The End
72</body>
73</html>
74"""
1fded56b
RD
75
76
77
78if __name__ == '__main__':
79 import sys,os
80 import run
8eca4fef 81 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
1fded56b 82