To view or update a shelve of instances of an imported Actor class, we can use code
like this:
from PP4E.Dbase.testdata inport Actor
from formgui import FormGui # run in TableBrowser dir
from formtable import ShelveOfInstance
testfile = '../data/shelve' # external filename
table = ShelveOfInstance(testfile, Actor) # wrap shelf in Table object
FormGui(table).mainloop()
table.close() # close needed for some dbm
Figure 17-1 captures the scene under Python 3.1 and Windows 7 when viewing a shelve
of persistent class instance objects. This PyForm session was kicked off by a command-
line described in its form table module’s self-test code: formtable.py shelve 1, and
omit the 1 (or pass it as 0 ) to avoid reinitializing the shelve at the start of each session
so changes are retained.
PyForm’s GUI can also be started from the PyDemos launcher we met in Chapter 10,
though it does not save changes persistently in this mode. Run the example on your
own computer to get a better sample of its operation. Though not a fully general Python
persistent object table viewer, PyForm serves as a simple object database front end.
Figure 17-1. PyForm displaying a shelve of Actor objects
Because we are short on time and space in this edition, I’m going to omit both the
source code for this example and its description here. To study PyForm, see the fol-
lowing directory in the book’s examples package distribution described in the Preface:
C:\...\PP4E\Dbase\TableBrowser
PyForm: A Persistent Object Viewer (External) | 1357