This is the same problem as in my previous question, but I moved to python3/gtk3 to be able to use a css for setting the basic properties.
From the python file:
self.w = Gtk.Window()
self.w.set_name("App")
I can use a css:
#App GtkTreeView row:selected {
border-color: #000000;
border-top-width: 1px;
border-bottom-width: 1px;
color: #000;
}
And easily permanently change the style of the selection. To me this means that I should be able to dynamically get access to the row
-object and its style where I could set the bg
for the Gtk.StateFlags.SELECTED
.
I've tried a bunch of weird ways, e.g (where bg_color
is a Gdk.Color
that works fine for e.g. changing the style of a Label
outside the TreeView
).
style=self.treeview.get_style_context()
col = style.get_background_color(Gtk.StateFlags.SELECTED)
col.alpha = 1.0
col.blue = bg_color.blue
col.red = bg_color.red
col.green = bg_color.green
Or:
style = self.treeview.get_style().copy()
style.bg[Gtk.StateFlags.SELECTED] = bg_color
self.treeview.set_style(style)
(produces error: style.bg[Gtk.StateFlags.SELECTED] = bg_color
IndexError: list assignment index out of range
)
etcetera...
So please, how do I find the way to dynamically change the selection effect depending on the normal-color of the row? Or in other words, how do I find my way to the object that actually holds the style-setting for the selection?