Gtk Tree View code
using Gtk
ts = GtkTreeStore(String, String, String, String)
tv = GtkTreeView(GtkTreeModel(ts))
# specific renderers for each of the columns:
rTxt = GtkCellRendererText()
c0 = GtkTreeViewColumn("#", rTxt, Dict([("text", 0)]))
c1 = GtkTreeViewColumn("Name", rTxt, Dict([("text", 1)]))
c2 = GtkTreeViewColumn("Weight", rTxt, Dict([("text", 2)]))
c3 = GtkTreeViewColumn("Units", rTxt, Dict([("text", 3)]))
push!(tv, c0, c1, c2, c3)
# Make columns resizable:
for c in [c0, c1, c2, c3]
GAccessor.resizable(c, true)
end
# Make columns sortable:
for (i,c) in enumerate([c0,c1,c2,c3])
GAccessor.sort_column_id(c, i-1)
end
# Add data to treeview:
iter1 = push!(ts, ("1", "FRUITS", "", ""))
push!(ts, ("1", "Oranges", "1000", "kg"), iter1)
push!(ts, ("2", "Apples", "500", "lb"), iter1)
push!(ts, ("3", "Kiwis", "300", "kg"), iter1)
iter2 = push!(ts, ("2","VEGETABLES","",""))
push!(ts, ("1", "Lettuce", "20", "lb"), iter2)
push!(ts, ("2", "Avocado", "150", "kg"), iter2)
iter3 = push!(ts, ("3","CEREALS","",""))
push!(ts, ("1", "Wheat", "2.5", "ton"), iter3)
push!(ts, ("2", "Rice", "5.0", "ton"), iter3)
# Display
win = GtkWindow(tv, "Tree View")
Gtk.showall(win)