This section introduces the Kiwi framework, and shows the use cases that each of the main classes were designed for. Throughout this guide, I'll be showing code examples that are included in the distribution (in the examples/ directory); just install Kiwi and you are ready to run them. To start off with, I'll show a very simple Kiwi application that saves information defined in a graphical form. This app is included in examples/framework/person/person.py. Note that this app uses the glade file Person.glade.
#!/usr/bin/env python import gtk from kiwi.model import PickledModel from kiwi.ui.delegates import ProxyDelegate # define the class that holds our application data class Person(PickledModel): pass person = Person.unpickle() # create and run a proxy interface attached to person view = ProxyDelegate(person, gladefile="Person", widgets=["address", 'name', 'phone'], delete_handler=gtk.main_quit) view.focus_topmost() view.show_and_loop() # save changes done to the instance person.save()
This application (17 lines) renders an interface to edit personal data, transparently saving and loading it. A quick glance at the code:
Person.unpickle()
loads (creating, if it didn't exist) a
Person instance.
This example is a summary of many Kiwi features; it exemplifies the Proxy class, which is one of the more featureful parts of the framework. This guide will take you gradually through the different classes in Kiwi, and the next section begins by describing the general Kiwi architecture.