Mercurial > fife-parpg
comparison engine/extensions/pychan/widgets/common.py @ 248:a2d5e2721489
widgets.py split up.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 26 Mar 2009 16:20:16 +0000 |
parents | |
children | 1cc51d145af9 |
comparison
equal
deleted
inserted
replaced
247:040387b7167f | 248:a2d5e2721489 |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 import fife | |
4 import pychan.tools as tools | |
5 import pychan.events as events | |
6 from pychan.exceptions import * | |
7 from pychan.attrs import Attr,UnicodeAttr, PointAttr,ColorAttr,BoolAttr,IntAttr,FloatAttr | |
8 from pychan.properties import ColorProperty | |
9 | |
10 | |
11 def get_manager(): | |
12 import pychan | |
13 return pychan.manager | |
14 | |
15 def text2gui(text): | |
16 """ | |
17 This function is applied to all text set on widgets. | |
18 It replaces tabs by four spaces. | |
19 It assumes the text to be a unicode object. | |
20 """ | |
21 if not isinstance(text,unicode): | |
22 print "Widget text needs to be set from an unicode object. Got: '%s'" % repr(text) | |
23 text = unicode(text,"utf8") | |
24 return text.encode("utf8",*get_manager().unicodePolicy).replace("\t"," "*4).replace("[br]","\n") | |
25 | |
26 def gui2text(text): | |
27 """ | |
28 This function is applied to all text get from widgets. | |
29 Translates the encoded string into a unicode object. | |
30 """ | |
31 return unicode(text,"utf8",*get_manager().unicodePolicy) | |
32 | |
33 def isLayouted(widget): | |
34 from containers import LayoutBase | |
35 return isinstance(widget,LayoutBase) | |
36 | |
37 class DummyImage(object): | |
38 def getWidth(self): return 0 | |
39 def getHeight(self): return 0 |