Mercurial > fife-parpg
comparison clients/editor/scripts/gui/statusbar.py @ 255:51cc05d862f2
Merged editor_rewrite branch to trunk.
This contains changes that may break compatibility against existing clients.
For a list of changes that may affect your client, see: http://wiki.fifengine.de/Changes_to_pychan_and_FIFE_in_editor_rewrite_branch
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 08 Jun 2009 16:00:02 +0000 |
parents | |
children | 62d1eebd1487 |
comparison
equal
deleted
inserted
replaced
254:10b5f7f36dd4 | 255:51cc05d862f2 |
---|---|
1 from pychan import widgets | |
2 | |
3 class StatusBar(widgets.HBox): | |
4 """ | |
5 A basic widget which displays information of the current status of the program. | |
6 | |
7 Use the text property to set the text to be displayed. Use showTooltip() to display | |
8 a temporary message. | |
9 """ | |
10 def __init__(self, text=u"", panel_size=25, *args, **kwargs): | |
11 super(StatusBar, self).__init__(*args, **kwargs) | |
12 self.min_size = (panel_size, panel_size) | |
13 | |
14 self._tooltip = None | |
15 self._label = widgets.Label(text=text) | |
16 self.addChild(self._label) | |
17 | |
18 def setText(self, text): | |
19 """ Sets the text to be displayed whenever a tooltip isn't displayed """ | |
20 self._label.text = text | |
21 | |
22 def getText(self): | |
23 return self._label.text | |
24 text = property(getText, setText) | |
25 | |
26 def showTooltip(self, text): | |
27 """ Shows a text which is visible until hideTooltip is called """ | |
28 if text == u"": | |
29 self.hideTooltip() | |
30 if self._tooltip is not None: | |
31 self._tooltip.text = text | |
32 else: | |
33 self.removeChild(self._label) | |
34 self._tooltip = widgets.Label(text=text) | |
35 self.addChild(self._tooltip) | |
36 self.adaptLayout() | |
37 | |
38 def hideTooltip(self): | |
39 """ Removes the text set by showTooltip. Whatever text previously set by setText is then displayed. """ | |
40 if self._tooltip is not None: | |
41 self.removeChild(self._tooltip) | |
42 self.addChild(self._label) | |
43 self._tooltip = None | |
44 self.adaptLayout() |