Improved the header frame so that it can be reset many times.

Also added an error message frame, which is packed at the bottom of the pane.
This commit is contained in:
David Soulayrol 2010-11-18 11:11:28 +01:00
parent 357803c00e
commit f19ddd3148

View file

@ -82,6 +82,13 @@ class Pane(gtk.VBox):
gtk.VBox.__init__(self, False, 5)
self._frame = frame
self._header = gtk.VBox()
self.pack_start(self._header, False)
self._error = gtk.VBox()
self.pack_end(self._error, False)
self._subject = None
self._switch = None
self._successors = {}
@ -111,11 +118,31 @@ class Pane(gtk.VBox):
explaining the current step, calling this method will ensure
such panes all present the same header style.
"""
help_label = gtk.Label(msg)
help_label.set_justify(gtk.JUSTIFY_FILL)
help_label.set_line_wrap(True)
self.pack_start(help_label, False, False, 10)
self.pack_start(gtk.HSeparator(), False, False)
self._header.foreach(lambda w: self._header.remove(w))
if msg:
help_label = gtk.Label(msg)
help_label.set_justify(gtk.JUSTIFY_FILL)
help_label.set_line_wrap(True)
self._header.pack_start(help_label, False, False, 10)
self._header.pack_start(gtk.HSeparator(), False)
self._header.show_all()
def set_error(self, msg):
"""Add a help header to the pane with the given message.
Since it is quite common that panes begin with a little guide
explaining the current step, calling this method will ensure
such panes all present the same header style.
"""
self._error.foreach(lambda w: self._error.remove(w))
if msg:
error_label = gtk.Label()
error_label.set_markup(
'<span foreground="red" weight="bold">' + msg + '</span>')
error_label.set_justify(gtk.JUSTIFY_FILL)
error_label.set_line_wrap(True)
self._error.pack_start(error_label, False, False, 10)
self._error.show_all()
def switch(self, klass):
"""Update the switch using the given class.