python - Button not getting styled in PyGI -
i trying create button red instead of default colour. applying style through cssprovider()
button's colour not change. doing wrong ?
here code:
from gi.repository import gtk, gdk css = """ gtkbutton { background-color: red; } """ class mywindow(gtk.window): def __init__(self): gtk.window.__init__(self, title="theme") self.resize(640, 480) self.connect("delete-event", gtk.main_quit) cssprovider = gtk.cssprovider() cssprovider.load_from_data(css) screen = gdk.screen.get_default() sc = gtk.stylecontext() sc.add_provider_for_screen(screen, cssprovider, gtk.style_provider_priority_application) btn = gtk.button(label="click") self.add(btn) win = mywindow() win.show_all() gtk.main()
the problem background-image takes precedence on background-color, former set in theme (button gradient). can force complete replacement of background using "background" property or using "background-color" along un-setting "background-image":
gtkbutton { background: red; }
or:
gtkbutton { background-image: none; background-color: red; }
Comments
Post a Comment