1. EuGTK - change column label?
- Posted by Jerry_Story Sep 20, 2010
- 1222 views
I got EuGTK_4.2.2 happening.
The next problem is to change the label on a column in a list. In wxEuphoria, it is:
set_column_label(list, column, string)
I tried:
set(list,"title",column,string)
But
'GtkTreeView' has no property named `title'
2. Re: EuGTK - change column label?
- Posted by irv Sep 20, 2010
- 1208 views
I got EuGTK_4.2.2 happening.
The next problem is to change the label on a column in a list. In wxEuphoria, it is:
set_column_label(list, column, string)
I tried:
set(list,"title",column,string)
But
'GtkTreeView' has no property named `title'
That's 'cause a TreeView doesn't have a 'title' property, and if it did, that's not what you are wanting to change anyway :)
To change a column's title - just get the column you want to change from the treeview like so:
atom column = get(tv,"column",1) -- column 1 is actually the second column, thanks to C! set(column,"title","Foo!")
Hmm... ok, just for fun, instead of changing the title to some plain old text, let's put an animated gif in there instead:
constant img = create(GtkImage,"tiphat.gif") atom column = get(data,"column",3) set(column,"widget",img) show(img)
Works fine. Might even be useful. Put a blinking down-arrow in the column your user is supposed to be selecting from perhaps?
3. Re: EuGTK - change column label?
- Posted by Jerry_Story Sep 20, 2010
- 1159 views
atom column = get(tv,"column",1) -- column 1 is actually the second column, thanks to C! set(column,"title","Foo!")
global object lvFoods = CreateLV(8000) global constant lstFoods = List:View(lvFoods,{"food","N/100g","N/req cal"}) atom col col = get(lstFoods,"column",0) -- starts with 0 set(col,"title",sprintf("%d foods",{length(dl_Foods)}))
./eugtk_stuff/GtkEngine.e:466 in procedure set()
type_check failure, classname is 0
... called from ./dmak_actions.e:494 in procedure Load_dlFoods()
Line 494 is:
set(col,"title",sprintf("%d foods",{length(dl_Foods)}))
What did I do wrong?
4. Re: EuGTK - change column label?
- Posted by irv Sep 20, 2010
- 1154 views
atom column = get(tv,"column",1) -- column 1 is actually the second column, thanks to C! set(column,"title","Foo!")
global object lvFoods = CreateLV(8000) <== 1 global constant lstFoods = List:View(lvFoods,{"food","N/100g","N/req cal"}) atom col col = get(lstFoods,"column",0) -- starts with 0 <== 2 set(col,"title",sprintf("%d foods",{length(dl_Foods)}))
./eugtk_stuff/GtkEngine.e:466 in procedure set()
type_check failure, classname is 0
... called from ./dmak_actions.e:494 in procedure Load_dlFoods()
Line 494 is:
set(col,"title",sprintf("%d foods",{length(dl_Foods)}))
What did I do wrong?
1 - that creates separate text renderers, one for each column in your view. Probably want 3 or 4 there, not 8000!
2 - The "classname is 0" generally (always?) means that the control in question hasn't been registered with Eugtk. To make sure these columns get registered, add the marked lines to ListView.e:
Note: a call to setRow or setCol will also register the column - that's why my demo worked without the added lines.
export function View(sequence lv, object cols) atom tv = create(GtkTreeView) atom col -- add for i = 1 to length(cols) do addColumn(tv,lv[RENDERERS][i],cols[i],i-1) col = get(tv,"column",i-1) -- add register_object(col,GtkTreeViewColumn) -- add end for return tv end function