Mercurial > fife-parpg
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clients/editor/scripts/gui/statusbar.py Mon Jun 08 16:00:02 2009 +0000 @@ -0,0 +1,44 @@ +from pychan import widgets + +class StatusBar(widgets.HBox): + """ + A basic widget which displays information of the current status of the program. + + Use the text property to set the text to be displayed. Use showTooltip() to display + a temporary message. + """ + def __init__(self, text=u"", panel_size=25, *args, **kwargs): + super(StatusBar, self).__init__(*args, **kwargs) + self.min_size = (panel_size, panel_size) + + self._tooltip = None + self._label = widgets.Label(text=text) + self.addChild(self._label) + + def setText(self, text): + """ Sets the text to be displayed whenever a tooltip isn't displayed """ + self._label.text = text + + def getText(self): + return self._label.text + text = property(getText, setText) + + def showTooltip(self, text): + """ Shows a text which is visible until hideTooltip is called """ + if text == u"": + self.hideTooltip() + if self._tooltip is not None: + self._tooltip.text = text + else: + self.removeChild(self._label) + self._tooltip = widgets.Label(text=text) + self.addChild(self._tooltip) + self.adaptLayout() + + def hideTooltip(self): + """ Removes the text set by showTooltip. Whatever text previously set by setText is then displayed. """ + if self._tooltip is not None: + self.removeChild(self._tooltip) + self.addChild(self._label) + self._tooltip = None + self.adaptLayout()