I am using a treeview with checkboxes. I want the user to be able to click a checkbox and it will add that item to a favourites list. But currently I cannot get the boxes to toggle at all. Here's my code:
def draw_columns(self,treeview):
self.ren = gtk.CellRendererToggle()
self.ren.connect('toggled',self.on_toggle,treeview.get_model())
self.tvfav = gtk.TreeViewColumn('Fav',self.ren,text=7)
for i in [self.tvfav,'andall the other columns']:
treeview.append_column(i)
def on_toggle(self,cell,path_str,model):
toggle_item = model.get_value(iter,column)
toggle_item = not toggle_item
# This method didn't work either
## model[path_str][1] = not model[path_str][1]
if toggle_item:
#Add it to the favourite list if it isn't already
pass
else:
#remove it from the favourite list
pass
model.set(iter,column,toggle_item)
def __init__(self):'
....
self.liststore = gtk.ListStore(str,int, int, int,str, 'gboolean', str)
self.treeview = gtk.TreeView(self.liststore)
....
What am I doing wrong that the boxes can't be checked? Also, how would I set the toggle when items are appended to the treeview like this:
if name in favourites:
#Append to list with checkbox on
self.liststore.append([name,x,y,z,ss,True,sss])