1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 from fife import fife
25 from fife.extensions.pychan import tools
26 from fife.extensions.pychan import events
27 from fife.extensions.pychan.exceptions import *
28 from fife.extensions.pychan.attrs import Attr,UnicodeAttr, PointAttr,ColorAttr,BoolAttr,IntAttr,FloatAttr
29 from fife.extensions.pychan.properties import ColorProperty
30
31 AlignTop, AlignBottom, AlignLeft, AlignRight, AlignCenter = range(5)
32
36
38 """
39 This function is applied to all text set on widgets.
40 It replaces tabs by four spaces.
41 It assumes the text to be a unicode object.
42 """
43 if not isinstance(text,unicode):
44 print "Widget text needs to be set from an unicode object. Got: '%s'" % repr(text)
45 text = unicode(text,"utf8")
46 return text.encode("utf8",*get_manager().unicodePolicy).replace("\t"," "*4).replace("[br]","\n")
47
49 """
50 This function is applied to all text get from widgets.
51 Translates the encoded string into a unicode object.
52 """
53 return unicode(text,"utf8",*get_manager().unicodePolicy)
54
56 """
57 This function returns an 8-bit representation of the
58 unicode string. This is useful for passing strings
59 to SWIG functions.
60 """
61 try:
62 return text.__str__()
63 except:
64
65 return text.encode("utf-8")
66
70