ruby-****@sourc*****
ruby-****@sourc*****
2012年 9月 21日 (金) 02:36:41 JST
------------------------- REMOTE_ADDR = 184.145.80.187 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-parts ------------------------- @@ -303,7 +303,8 @@ renderer.text = "Yes, buy this product" renderer.foreground = "#ff0000" -This would only change the tree view but not the model. +This would only change the tree view but not the model. Also you must know where you can and can not change a renderer's attributes. For instance placing the line "renderer.text = 'Yes, buy this product'" in "setup_tree_view" method would have no effect, however setting the value of "foreground" attribute would work. The best place to change renderer's attributes is in the "Cell Data Function" which you do not learn as one of the basic tools here and we only explain in the next chapter since it is one of more exotic features of tree view management mechanisms but nevertheless used frequently. + To understand why the initialization of the column constructor above in the first of the two code snippet is wrong you must know that the :text and :foreground properties are the render's attributes. As pointed out in the discussion in the previous paragraph the values in the constructor's hash parameter should be integers since they represent the column numbers for the actual values of these attributes in the model. If you recall in the paragraph above entitled((*Navigating tree model*))we mentioned that most of the tree model interface consists of operations on a Gtk::TreeIter. If you look at the "liststore.rb" program listing above you will notice that these iterators are used to access the model as if it were an array: