pygtk treview, ListStore not displaying properly

B

binaryjesus

hi group i am running into a problem with gtk. i have a treeview that
just displays tabular data (no down arrows or trees etc). it has 5
columns. The tiny problem i am having is that it is just display the
data of the column named `title` in all the colums!

here the pic of the app in action
http://i36.tinypic.com/2djcqqr.png

the related code of the app is as follows:

self.tv = self.glade.get_widget('treeview1') #the treeview object

def show_sync_wind(self,obj, data = None):
t = Template.select(Template.q.synced == '0')
self.synclstore = gtk.ListStore(str,str,str,str,str)
x = 0
cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('#', cr);
col.add_attribute(cr, 'markup', 1)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(0)
self.tv.append_column(col)
self.sno_col = col

cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Title', cr);
col.add_attribute(cr, 'markup', 1)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(1)
self.tv.append_column(col)
self.title_col = col

cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Section', cr);
col.add_attribute(cr, 'markup', 1)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(2)
self.tv.append_column(col)
self.section_col = col

cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Category', cr);
col.add_attribute(cr, 'markup', 1)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(3)
self.tv.append_column(col)
self.category_col = col

cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Sync', cr);
col.add_attribute(cr, 'markup', 1)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(4)
self.tv.append_column(col)
self.sync_col = col

self.tv.set_model(self.synclstore)
self.tv.set_headers_clickable(True)
#self.tv.set_expander_column(self.title_col)
for y in t:
row =
self.synclstore.append([str(x),y.title,y.section.name,y.category.name,y.synced])
self.synclstore.set(row,0,'0')
self.synclstore.set(row,1,y.title)
self.synclstore.set(row,2,y.section.name)
self.synclstore.set(row,3,y.category.name)
self.synclstore.set(row,4,y.synced)
self.sync_window.show()
 
B

binaryjesus

finally i solved it. This for any googler who comes this way

def show_sync_wind(self,obj, data = None):
t = Template.select(Template.q.synced == '0')
self.synclstore = gtk.ListStore(str,str,str,str,str)
x = 0
cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('#', cr);
col.set_attributes(cr, text=0)#<------ attaches col to the 0`th item
of liststore
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(0)
self.tv.append_column(col)
self.sno_col = col

cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Title', cr);
col.set_attributes(cr, text=1)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(1)
self.tv.append_column(col)
self.title_col = col

cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Section', cr);
col.set_attributes(cr, text=2)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(2)
self.tv.append_column(col)
self.section_col = col

cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Category', cr);
col.set_attributes(cr, text=3)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(3)
self.tv.append_column(col)
self.category_col = col

cr = gtk.CellRendererText()
col = gtk.TreeViewColumn('Sync', cr);
col.set_attributes(cr, text=4)
col.set_expand(True)
col.set_clickable(True)
col.set_resizable(True)
col.set_sort_column_id(4)
self.tv.append_column(col)
self.sync_col = col

self.tv.set_model(self.synclstore)
self.tv.set_headers_clickable(True)
#self.tv.set_expander_column(self.title_col)
for y in t:
x = x+1
row =
self.synclstore.append([str(x),y.title,y.section.name,y.category.name,y.synced])
self.sync_window.show()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,834
Latest member
BuyCannaLabsCBD

Latest Threads

Top