Re: Two SimpleLists with one data stucture




On May 29, 2006, at 11:50 AM, Vasya Leushin wrote:

I got stuck in another problem. This time I need to represent this
structure in one (simple?)list in following manner.

 $v = [[ 1,'Color1',128,[[10,5,'White'],[20,15,'Blue'],]]];
       |__|_______|____|______________________________|
cols     1    2      3       4

Column 4 is a CellRendererCombo. 'White','Blue' are entries in Combo
which works like this:
if i choose 'White' in Combo, then value in column 3 is set to 5,
if i choose 'Blue' column 3 is set to 15 and so on...

Welcome to the world of Things That SimpleList Should Not Be Twisted Into Doing.

SimpleList doesn't know how to use CellRendererCombo. Making it use one will result in such a twisted mess that you'd be better off dropping SimpleList and using the bare TreeModel/TreeView APIs directly. In either case, you'll get to know those APIs pretty well, and it's easier if you have a blank slate instead of trying to squeeze things into the SimpleList framework.

(I'm not saying don't use SimpleList. I'm saying use SimpleList for Simple Lists, not complicated ones.)


The first thing to remember is that the model and the view are not the same. Above, you showed the outline of the data structure that lives in the model, and then said "Column 4 is a CellRendererCombo". The model knows nothing of cell renderers, so you're obviously talking about the view, but i am confused as to whether you're implying that the data in column 4 should also be showing in the cell.

Also, the cell editing is not automatic. With CellRendererCombo, you'll have to set the "editable" property to true for the cell to be in any way distinguishable from a CellRendererText, and then you'll have to connect a handler to the CellRenderText's "edited" signal and figure out how to apply the user's changes to your data structures.

Some questions come up that prevent me coming up with a useful example... what should the combo renderer display when not showing the menu, what do the columns mean, etc, etc. Can you describe the context of the problem in a bit more detail?


--
"that's it! you're a genius!" "yes. that's what i think. do you think i deserve a raise?"
    - dialogue from 'Godzilla versus Mothra', 1964




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]