HY, 我已经做了构建一个工具,显示数据库的内容工作正常,但用户必须删除行中的按钮上的行。
这就是我现在设置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
现在我想添加一个新列,其中是用于打开删除对话框的按钮,但我找不到允许我在其中放置按钮的单元格渲染器。
我该怎么做?
答案 0 :(得分:1)
你是对的,没有像GtkButton那样工作的单元格渲染器,所以唯一的方法就是编写自己的单元格渲染器对象。
Here是编写自己的渲染器的指南,虽然它是为C编写的,但原理是相同的。