#!/usr/bin/python # a simple, essentially useless program that uses pyGTK and ZODB; I # currently run it with pyGTK 0.6.9-3 and ZODB 3.1.1 on Python 2.1.1. # I'd hoped to build something a little closer to usability tonight, # but 2 hours was only enough time to write essentially 'hello world' # in GTK and ZODB. Maybe I'll have more luck next time. import gtk from ZODB import FileStorage, DB from Persistence import Persistent
storage = FileStorage.FileStorage('hellodb.fs') db = DB(storage) conn = db.open() class hello(Persistent): def __init__(self): self.count = 0 def hellocount(self): self.count += 1 return 'Has been called %d times' % self.count dbroot = conn.root() if not dbroot.has_key('hello'): dbroot['hello'] = hello() window = gtk.GtkWindow(gtk.WINDOW_TOPLEVEL) window.connect("destroy", gtk.mainquit) window.set_border_width(10) window.set_title("Mail index") vbox = gtk.GtkVBox() window.add(vbox) button = gtk.GtkButton("Close") button.connect("clicked", lambda win: window.destroy()) vbox.pack_start(button, expand=gtk.FALSE) thelist = gtk.GtkCList(2, ["From", "Subject"]) thelist.append(['[EMAIL PROTECTED]', 'I have a book you might like']) thelist.append(['[EMAIL PROTECTED]', 'How are you?']) thelist.columns_autosize() vbox.pack_start(thelist) window.show_all() thelist.append(['ZODB says', str(dbroot['hello'].hellocount())]) get_transaction().commit() gtk.mainloop() -- <[EMAIL PROTECTED]> Kragen Sitaker <http://www.pobox.com/~kragen/> Edsger Wybe Dijkstra died in August of 2002. The world has lost a great man. See http://advogato.org/person/raph/diary.html?start=252 and http://www.kode-fu.com/geek/2002_08_04_archive.shtml for details.