gtk, clist & python
Skip Montanaro
montanaro at tttech.com
Fri Nov 9 10:55:30 EST 2001
jm> how can i do the mapping between rows of a "clist" and a python's
jm> vector?
jm> how can i know the number of rows in a "clist"?
These are questions probably better asked on the pygtk mailing list, but
I'll take a stab at it (I've never used this particular widget). I don't
see any obvious "length" method, so I think you'll just have to keep track
of the size as you call the append() and insert() methods to add rows to the
widget. Both return the offset of the row just added as the script below
demonstrates. (I use the Gtk 2.0 API, so you may have to fiddle the script
to make it work with the older API.)
#!/usr/bin/env python
import gtk
win = gtk.Window()
win.connect("destroy", gtk.mainquit)
vb = gtk.VBox()
win.add(vb)
cl = gtk.CList(1)
items = "foo bar baz".split()
for item in items:
print "row:", cl.append([item])
vb.pack_start_defaults(cl)
b = gtk.Button("quit")
b.connect("clicked", gtk.mainquit)
vb.pack_start(b)
win.show_all()
gtk.mainloop()
--
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/
More information about the Python-list
mailing list