Hi All, I have attached a small program which lists the top 20 movies from the imdb database. The 'Rating' column is Glib::Double and when it is displayed in the treeview it shows a rating as: 9.200000. Is someone able to show me how to use the set_cell_data_func: http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/TreeViewColumn.html#_tree_column_set_cel to limit the number of digits on the right hand side of the decimal point? (Assuming this is what I should be using). I don't really understand how to call a function like this and where it gets it parameters from or if it passes any parameters onto '$func'. In my sub for the treeview I have played around with the following but am not getting very far. sub setup_treeview { .... my $tc_rating = Gtk2::TreeViewColumn->new(); $tc_rating->set_title("Rating"); $tc_rating->pack_start($renderer, FALSE); $tc_rating->add_attribute($renderer, text => RATING_COL); # $tree_column->set_cell_data_func ($cell_renderer, $func, $data=undef) $tc_rating->set_cell_data_func($renderer, &limit_digits, undef); .... } .... sub limit_digits { my ($column, $cell, $model, $iter, $func_data) = @_; $figure = $model->get($iter, RATING_COL); $cell = sprintf("%.1f", $figure); } Not sure how to provide limit_digits with all of the required parameters and get a defined model to it as am currently getting a 'Can't call method "get" on an undefined value at main.pl line 181.' error when trying to run the program. If someone could point me in the right direction or show me a working example that would be great.
Attachment:
main.pl
Description: Binary data
Attachment:
TreeViewSearch.glade
Description: Binary data