Mercurial > fife-parpg
comparison tools/editor/scripts/gui/statusbar.py @ 378:64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 11 Jan 2010 23:34:52 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
377:fe6fb0e0ed23 | 378:64738befdf3b |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 # #################################################################### | |
4 # Copyright (C) 2005-2009 by the FIFE team | |
5 # http://www.fifengine.de | |
6 # This file is part of FIFE. | |
7 # | |
8 # FIFE is free software; you can redistribute it and/or | |
9 # modify it under the terms of the GNU Lesser General Public | |
10 # License as published by the Free Software Foundation; either | |
11 # version 2.1 of the License, or (at your option) any later version. | |
12 # | |
13 # This library is distributed in the hope that it will be useful, | |
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 # Lesser General Public License for more details. | |
17 # | |
18 # You should have received a copy of the GNU Lesser General Public | |
19 # License along with this library; if not, write to the | |
20 # Free Software Foundation, Inc., | |
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
22 # #################################################################### | |
23 | |
24 from fife.extensions.pychan import widgets | |
25 | |
26 class StatusBar(widgets.HBox): | |
27 """ | |
28 A basic widget which displays information of the current status of the program. | |
29 | |
30 Use the text property to set the text to be displayed. Use showTooltip() to display | |
31 a temporary message. | |
32 """ | |
33 def __init__(self, text=u"", panel_size=25, *args, **kwargs): | |
34 super(StatusBar, self).__init__(*args, **kwargs) | |
35 self.min_size = (panel_size, panel_size) | |
36 | |
37 self._tooltip = None | |
38 self._label = widgets.Label(text=text) | |
39 self.addChild(self._label) | |
40 | |
41 self._text = u"" | |
42 self._tooltipDisplayed = False | |
43 | |
44 def setText(self, text): | |
45 """ Sets the text to be displayed whenever a tooltip isn't displayed """ | |
46 self._text = text | |
47 if not self.isTooltipDisplayed(): | |
48 self._label.text = text | |
49 | |
50 def getText(self): | |
51 return self._text | |
52 text = property(getText, setText) | |
53 | |
54 def showTooltip(self, text): | |
55 """ Shows a text which is visible until hideTooltip is called """ | |
56 self._label.text = text | |
57 self._tooltipDisplayed = True | |
58 | |
59 def hideTooltip(self): | |
60 """ Removes the text set by showTooltip. Whatever text previously set by setText is then displayed. """ | |
61 self._label.text = self._text | |
62 self._tooltipDisplayed = False | |
63 | |
64 def isTooltipDisplayed(self): | |
65 """ Returns true if tool tip is displayed """ | |
66 return self._tooltipDisplayed |