-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dear all,
The attached python script works fine when I call it as 'python test.py', i.e. the cells of the tables are filled with text (python.jpg; Python 2.7.3, Debian testing). When I run the script from coot (0.7, svn 4459, built on this machine), the cells remain empty (coot.jpg). Since Berhard Lohkamp told me he cannot reproduce the error I was wondering if anyone could point out how to debug this problem. A start would be a hint as to how figure out which libraries and packages are involved and how to differentiate between the once found within the coot installation and those which are system installed (and thus make the code work when called as 'python test.py'). I appreciate any comment, including ways how to create such a table view in a different (more stable/ reliable) way. Best, Tim - -- - -- Dr Tim Gruene Institut fuer anorganische Chemie Tammannstr. 4 D-37077 Goettingen GPG Key ID = A46BEE1A -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iD8DBQFQ/7oiUxlJ7aRr7hoRAgqlAJ99xc2N0l5mLSnW3gK4gL1nYwjAsQCfWoqG CKcsVZBPQ6f6Y3dreoqUZcA= =GTab -----END PGP SIGNATURE-----
<<attachment: coot.jpg>>
<<attachment: python.jpg>>
#!/usr/bin/env python
# example treeviewcolumn.py
import pygtk
import gtk
print "Howdy"
class TreeViewColumnExample:
# close the window and quit
def delete_event(self, widget, event, data=None):
gtk.main_quit()
return False
def make_pb(self, tvcolumn, cell, model, iter):
stock = model.get_value(iter, 1)
pb = self.treeview.render_icon(stock, gtk.ICON_SIZE_MENU, None)
cell.set_property('pixbuf', pb)
return
def __init__(self):
# Create a new window
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("TreeViewColumn Example")
#self.window.set_size_request(200, 200)
self.window.connect("delete_event", self.delete_event)
# create a liststore with one string column to use as the model
self.liststore = gtk.ListStore(str, str, str, 'gboolean')
# create the TreeView using liststore
self.treeview = gtk.TreeView(self.liststore)
# create the TreeViewColumns to display the data
self.tvcolumn = gtk.TreeViewColumn('Pixbuf and Text')
self.tvcolumn1 = gtk.TreeViewColumn('Text Only')
# add a row with text and a stock item - color strings for
# the background
self.liststore.append(['Open', gtk.STOCK_OPEN, 'Open a File', True])
self.liststore.append(['New', gtk.STOCK_NEW, 'New File', True])
self.liststore.append(['Print', gtk.STOCK_PRINT, 'Print File', False])
# add columns to treeview
self.treeview.append_column(self.tvcolumn)
self.treeview.append_column(self.tvcolumn1)
# create a CellRenderers to render the data
self.cellpb = gtk.CellRendererPixbuf()
self.cell = gtk.CellRendererText()
self.cell1 = gtk.CellRendererText()
# set background color property
self.cellpb.set_property('cell-background', 'yellow')
self.cell.set_property('cell-background', 'cyan')
self.cell1.set_property('cell-background', 'pink')
# add the cells to the columns - 2 in the first
self.tvcolumn.pack_start(self.cellpb, False)
self.tvcolumn.pack_start(self.cell, True)
self.tvcolumn1.pack_start(self.cell1, True)
# set the cell attributes to the appropriate liststore column
# GTK+ 2.0 doesn't support the "stock_id" property
if gtk.gtk_version[1] < 2:
self.tvcolumn.set_cell_data_func(self.cellpb, self.make_pb)
else:
self.tvcolumn.set_attributes(self.cellpb, stock_id=1)
self.tvcolumn.set_attributes(self.cell, text=0)
self.tvcolumn1.set_attributes(self.cell1, text=2,
cell_background_set=3)
# make treeview searchable
self.treeview.set_search_column(0)
# Allow sorting on the column
self.tvcolumn.set_sort_column_id(0)
# Allow drag and drop reordering of rows
self.treeview.set_reorderable(True)
self.window.add(self.treeview)
self.window.show_all()
def main():
gtk.main()
if __name__ == "__main__":
tvcexample = TreeViewColumnExample()
main()
"""
### knuspr = Knuspr()
coot_knuspr = coot_menubar_menu ("_Test")
knuspr_menuitem = gtk.MenuItem("Knuspr Nucleic Acid Tracing")
coot_knuspr.append(knuspr_menuitem)
#knuspr_menuitem.destroy()
knuspr_menuitem.show()
knuspr_menuitem.connect("activate", TreeViewColumnExample )"""
