pygtk treview, ListStore not displaying properly

Discussion in 'Python' started by binaryjesus, Jul 29, 2008.

  1. binaryjesus

    binaryjesus Guest

    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()
     
    binaryjesus, Jul 29, 2008
    #1
    1. Advertising

  2. binaryjesus

    binaryjesus Guest

    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()
     
    binaryjesus, Jul 29, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sapo
    Replies:
    0
    Views:
    570
  2. Guillermo Heizenreder

    [pygtk] problem with TreeView + ListStore

    Guillermo Heizenreder, Sep 4, 2007, in forum: Python
    Replies:
    1
    Views:
    396
  3. Vinki
    Replies:
    2
    Views:
    331
    Patrice
    Dec 23, 2009
  4. Mark

    Errors running treview

    Mark, Jan 26, 2004, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    123
    Mark Goldin
    Jan 28, 2004
  5. AR

    treview does not maintain state

    AR, May 8, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    133
    Prakash V
    Jun 7, 2006
Loading...

Share This Page