# Listview grouping popup window examples

**URL:** <https://discourse.julialang.org/t/listview-grouping-popup-window-examples/96092>\
**Category:** Visualization\
**Tags:** gtk, gui\
**Created:** [March 14, 2023, 10:32pm UTC](https://discourse.julialang.org/t/listview-grouping-popup-window-examples/96092 "2023-03-14T22:32:50Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [March 18, 2023, 12:05pm UTC](https://discourse.julialang.org/t/listview-grouping-popup-window-examples/96092/7 "2023-03-18T12:05:32Z")

</div>

In case it might help others, I have copied below the `Gtk.jl` code used to produce the following scrollable `Tree View`:

 ![GtkScrolledWindow_GtkTreeView](https://global.discourse-cdn.com/julialang/original/3X/7/c/7c827b024fbbcfde5015a34cca4d26074f4b21c6.png)

> **Scrollable Gtk Tree View code**
>
> ```julia
> using Gtk, Printf
> 
> ts = GtkTreeStore(String, String, String, String)
> tv = GtkTreeView(GtkTreeModel(ts))
> sw = GtkScrolledWindow(tv)
> 
> # 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, ("", "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, ("","VEGETABLES","",""))
> push!(ts, ("1", "Lettuce", 20, "lb"), iter2)
> push!(ts, ("2", "Avocado", 150, "kg"), iter2)
> 
> iter3 = push!(ts, ("","CEREALS","",""))
> for i in 1:100
> push!(ts, (@sprintf("%3i",i), rand(("Wheat","Rice","Oat")), rand(0:100), "ton"), iter3)
> end
> 
> # Display
> win = GtkWindow(sw, "Tree View")
> Gtk.showall(win)
> 
> ```

_Q: How to set background colors to distinguish different rows?_

---

_[View the full topic](https://discourse.julialang.org/t/listview-grouping-popup-window-examples/96092)._
