From f19ddd314850e0180a73230c136bfe6e6dd34693 Mon Sep 17 00:00:00 2001 From: David Soulayrol Date: Thu, 18 Nov 2010 11:11:28 +0100 Subject: [PATCH] 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. --- wizpym.py | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/wizpym.py b/wizpym.py index 6ca1d16..bdcbe47 100644 --- a/wizpym.py +++ b/wizpym.py @@ -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( + '' + msg + '') + 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.