0

嗨,我已经构建了一个工具,该工具显示数据库的内容工作正常,但用户必须在单击行中的按钮时删除行。

这就是我现在用来设置 ListStore

def setup_tree_view(treeview)
 renderer = Gtk::CellRendererText.new
 renderer.foreground = "#ff0000"
 column   = Gtk::TreeViewColumn.new("Bestellnummer", renderer, :text => ID)
 treeview.append_column(column)
 renderer = Gtk::CellRendererText.new
 column   = Gtk::TreeViewColumn.new("Produkt", renderer,  :text => PRODUCT)
 treeview.append_column(column)
 renderer = Gtk::CellRendererText.new
 column   = Gtk::TreeViewColumn.new("Kunde", renderer, :text => CUSTOMER)
 treeview.append_column(column)
 renderer = Gtk::CellRendererText.new
 renderer = Gtk::CellRendererText.new
 column   = Gtk::TreeViewColumn.new("Kontakt", renderer, :text => CONTACT)
 treeview.append_column(column)
 renderer = Gtk::CellRendererToggle.new
 renderer.set_activatable true
 renderer.signal_connect('toggled') do |renderer, path|
   @handler.updateData ((@store.get_iter path).get_value ID), "ordered", toInt( (!((@store.get_iter path).get_value ORDERED)))
   @store.clear
   showData @handler.start
 end

 column   = Gtk::TreeViewColumn.new("Bestellt", renderer, :active => ORDERED)
 treeview.append_column(column)
 renderer = Gtk::CellRendererToggle.new
 renderer.signal_connect('toggled') do |renderer, path|
   @handler.updateData ((@store.get_iter path).get_value ID), "arrived", toInt( (!((@store.get_iter path).get_value ARRIVED)))
   @store.clear
   showData @handler.start
 end
 column   = Gtk::TreeViewColumn.new("Angekommen", renderer, :active => ARRIVED)
 treeview.append_column(column)
 renderer = Gtk::CellRendererToggle.new
 renderer.signal_connect('toggled') do |renderer, path|
   @handler.updateData ((@store.get_iter path).get_value ID), "informed", toInt( (!((@store.get_iter path).get_value ORDERED)))
   @store.clear
   showData @handler.start
 end
 column   = Gtk::TreeViewColumn.new("Informiert", renderer, :active => INFORMED)
 treeview.append_column(column)
end

现在我想添加一个新列,其中是打开删除对话框的按钮,但我找不到允许我将按钮放入其中的单元格渲染器。

我怎样才能做到这一点?

4

1 回答 1

1

你是对的,没有像 GtkButton 那样工作的单元格渲染器,所以唯一的方法是编写你自己的单元格渲染器对象。

是编写自己的渲染器的指南,虽然它是为 C 编写的,但原理是相同的。

于 2013-01-30T07:25:59.020 回答