PYTHON GTK - zebra stripes treeview

PYTHON GTK - zebra stripes treeview

if you need zebra stripes for your treeview you should do it like that.

at first you need a css file

for example widget.css includes

GtkTreeView row:nth-child(even) { background-color: shade(@base_color, 0.9); } GtkTreeView row:nth-child(odd) { background-color: shade(@base_color, 1.0); }

then you should add to your code

self.treeview.set_rules_hint(True) style_provider = Gtk.CssProvider() style_provider.load_from_path(‘widgets.css’)

Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(),                                    style_provider,                                    Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)