ruby-****@sourc*****
ruby-****@sourc*****
2012年 8月 26日 (日) 05:33:08 JST
------------------------- REMOTE_ADDR = 70.49.49.99 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-addrnhs ------------------------- @@ -567,10 +567,10 @@ We save the "path" of the iterator that points to the parent (our product category), and create a new row for our new product. Adding the data to the new empty row is accomplished by: - # child[$buy_it]=buy # same as: model.set_value(child, $buy_it, buy) - child[$buy_it] = buy - child[$quantity] = quantity - child[$product] = product + # child[BUY_INDEX]=buy # same as: model.set_value(child, BUY_INDEX, buy) + child[BUY_INDEX] = buy + child[QTY_INDEX] = quantity + child[PROD_INDEX] = product It is worth noticing the comment here which tells us that the Gtk::TreeIter#[column] and Gtk::TreeModel#set_value instance methods can be used interchangeably. @@ -578,9 +578,9 @@ if buy iter = model.get_iter(path) - qty_value = iter[$quantity] + qty_value = iter[QTY_INDEX] qty_value += quantity - iter[$quantity] = qty_value + iter[QTY_INDEX] = qty_value end === Combo Box