The GtkMe python lib provides a form window which allows me to construct a multi-page form with data validation. I’m pleased with the results I’ve committed today that allow a new user to register themselves within the login screen.
class RegisterWindow(TranslatableFormWindow):
"""Display a create user window"""
name = 'register'
primary = False
fields = [ 'postcode', 'age', 'gender', 'passphrase', 'computeruse' ]
def __init__(self, *args, **kwargs):
self.realname = kwargs.pop('real_name')
TranslatableFormWindow.__init__(self, *args, **kwargs)
intro = self.widget('label').get_label()
self.widget('label').set_label(intro % self.realname)
def cancel(self, widget, event=None):
if isinstance(widget, Gtk.Button) or (event and \
event.key.keyval == Gdk.KEY_Escape):
self.destroy()
def get_data(self):
"""Return all the user entered data"""
result = self.field_data()
result['name'] = self.realname
return result
def pre_exit(self):
register_service.create_user(self.get_data())
While I’m not finished debugging it all, the idea is to be able to make Gtk apps which have a wizard style layout with minimum effort. Each page has validation checks (if you want) and standard signals which you can stick into glade and have next, back, cancel and destroy handled for you.
This code controls a 5 page registration window as so:

Thoughts?