Set CSS style to GtkBox with python -
is posible alter background color of object gtkbox? far styles have worked in other objects gtkbox not work me know why? code
self.ventana = self.builder.get_object("ventana") self.header= self.builder.get_object("header") self.ventana.set_name('mywindow') self.header.set_name('header') self.style_provider = gtk.cssprovider() self.css=open(self.ruta+'/css/estilos.css','rb') self.css_data = self.css.read() self.style_provider.load_from_data(self.css_data) gtk.stylecontext.add_provider_for_screen(gdk.screen.get_default(),self.style_provider, gtk.style_provider_priority_application) /*********css styles *********/ #mywindow { background-color: #1d1d1d; } /*i seek whit: #mywindow #header, #mywindow gtkbox */ #header{ background-color: #ffffff; border-bottom: 1px solid white; }
the problem not gtk widgets draw own background. background determined underlying widget. behavior changed some widgets gtk+ 3.12.
so changing background color of gtk.box not work version < gtk+ 3.12. if using older version, alternative approach utilize gtk.viewport underneath gtk.box , alter color of viewport.
to set code:
box = gtk.box() viewport = gtk.viewport() viewport.add(box) #and cssprovder, stylecontext,...
css:
gtkviewport { background-color: red; )
python css python-3.x pygtk
No comments:
Post a Comment