Mercurial > fife-parpg
comparison engine/extensions/pychan/widgets/label.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 | 51cc05d862f2 |
comparison
equal
deleted
inserted
replaced
247:040387b7167f | 248:a2d5e2721489 |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 from common import * | |
4 from basictextwidget import BasicTextWidget | |
5 | |
6 class Label(BasicTextWidget): | |
7 """ | |
8 A basic label - displaying a string. | |
9 | |
10 Also allows text wrapping and onMouse hover callbacks. | |
11 | |
12 New Attributes | |
13 ============== | |
14 | |
15 - wrap_text: Boolean: Enable/Disable automatic text wrapping. Disabled by default. | |
16 Currently to actually see text wrapping you have to explicitly set a max_size with | |
17 the desired width of the text, as the layout engine is not capable of deriving | |
18 the maximum width from a parent container. | |
19 | |
20 """ | |
21 | |
22 ATTRIBUTES = BasicTextWidget.ATTRIBUTES + [BoolAttr('wrap_text')] | |
23 | |
24 def __init__(self,wrap_text=False,**kwargs): | |
25 self.real_widget = fife.Label("") | |
26 self.wrap_text = wrap_text | |
27 super(Label,self).__init__(**kwargs) | |
28 | |
29 def resizeToContent(self): | |
30 self.real_widget.setWidth( self.max_size[0] ) | |
31 self.real_widget.adjustSize() | |
32 self.height = self.real_widget.getHeight() + self.margins[1]*2 | |
33 self.width = self.real_widget.getWidth() + self.margins[0]*2 | |
34 #print self.width,self.max_size[0] | |
35 | |
36 def _setTextWrapping(self,wrapping): self.real_widget.setTextWrapping(wrapping) | |
37 def _getTextWrapping(self): self.real_widget.isTextWrapping() | |
38 wrap_text = property(_getTextWrapping,_setTextWrapping) | |
39 | |
40 class ClickLabel(Label): | |
41 """ | |
42 Deprecated - use L{Label} instead. | |
43 """ | |
44 __init__ = tools.this_is_deprecated(Label.__init__,message = "ClickLabel - Use Label instead") |