You are not logged in.
I'm creating my first python gui app. A small todo list, nothing fancy. I have all the underlying code working I just need to format my Treeview in the desired way. This is where the problem lies.
Is there anyway to hide a particular cell, or change a render on a cell by cell basis. For instance I have a list of tasks in the first column and the second column has a checkbox. Now on category titles I do not want to have the checkbox visible as it is not classified as a task, is there any way to achieve this ?
Thanks for your help
Edit: should have mentioned I'm using pygtk.
Last edited by passbe (2010-02-10 08:52:37)
Offline
maybe define a callback to the column with set_cell_data_func: http://library.gnome.org/devel/pygtk/st … -data-func
and modify the cell yourself.
Last edited by lman (2010-02-08 08:06:06)
Offline
@lman: I should have mentioned I have tried that, once I define that function and get the CellRenderer, i can only ever refer to the entire column and not that individual cell.
Offline
I used it before, and it worked for me. I used it to highlight the current track in a playlist.
[url=http://code.google.com/p/etude-music-player/source/browse/etude/gui/collview.py#212]example[url]see the current_highlight function
Edit: try using the iter variable to get data from other columns/same column to filter
Last edited by lman (2010-02-08 10:34:54)
Offline
So I have setup the function, but when adding the visible = false property to hide the toggle box for that one cell, it hides the entire cellrenderer ie the entire column.
self.cellrender_complete = gtk.CellRendererToggle()
self.col_complete = gtk.TreeViewColumn('Complete', self.cellrender_complete, active=3)
self.treeview.append_column(self.col_complete)
self.col_complete.set_cell_data_func(self.cellrender_complete, self.currentCell)
and the current cell function
def currentCell(self, column, cell, model, iter):
if self.treestore.get_value(iter, 1) == 'C':
cell.set_property('visible', False)
Offline
Do you have the whole code on a public page, so I can try it out myself?
Why not use the 'model' from the parameters instead of 'self.treestore'?
Offline
I do: http://github.com/trcm/todo/blob/gui2/todo.py you will see line 47 is where I bind the function, and line 71 is where I attempt to set the visible status to that cell.
Yes I do need to store the parameters in the model, need to sort that out.
Offline
I'm not sure exactly why, but you should set it back to visible, when it's not a category. This worked for me:
def currentCell(self, column, cell, model, iter):
if model.get_value(iter, 1) == 'C':
cell.set_property('visible', False)
else:
cell.set_property('visible', True)
Last edited by lman (2010-02-10 08:51:07)
Offline
that worked a treat, can't believe I didn't think to do that. thank you for your help.
Offline