gem install gtk3
なるべくシンプルにしてみたらこんな感じになった。
改良の余地があるはず。
require 'gtk3'
require 'csv'
require 'open-uri'
url = "https://raw.githubusercontent.com/pandas-dev/pandas/master/pandas/tests/data/iris.csv"
iris = CSV.parse(URI.open(url))
ls = Gtk::ListStore.new(*([String] * 5))
mf = ls.create_filter
treeview = Gtk::TreeView.new(mf)
iris.shift.each_with_index do |header, i|
column = Gtk::TreeViewColumn.new(header, Gtk::CellRendererText.new, text: i)
treeview.append_column(column)
end
iris.each do |val|
iter = ls.append
iter.values = val
end
win = Gtk::Window.new
win.title = 'Gtk::TreeModelFilter sample'
win.set_size_request 500, 400
sw = Gtk::ScrolledWindow.new
sw.add_with_viewport(treeview)
win.add sw
win.signal_connect('destroy') { Gtk.main_quit }
win.show_all
Gtk.main