简体   繁体   中英

GTK: Modify bg color of a CheckButton

I tried the following, yet the button still has a white background:

    self.button = gtk.CheckButton()
    self.button.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(65535,0,0))
    self.button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(65535,0,0))
    self.button.modify_fg(gtk.STATE_ACTIVE, gtk.gdk.Color(65535,0,0))
    self.button.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.Color(65535,0,0))
    self.button.modify_fg(gtk.STATE_PRELIGHT, gtk.gdk.Color(65535,0,0))
    self.button.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(65535,0,0))
    self.button.modify_fg(gtk.STATE_SELECTED, gtk.gdk.Color(65535,0,0))
    self.button.modify_bg(gtk.STATE_SELECTED, gtk.gdk.Color(65535,0,0))
    self.button.modify_fg(gtk.STATE_INSENSITIVE, gtk.gdk.Color(65535,0,0))
    self.button.modify_bg(gtk.STATE_INSENSITIVE, gtk.gdk.Color(65535,0,0))

I also added the CheckButton to an EventBox, and changed the color of that, but all it did is set the background of the space around the button - the button itself was still w/ a white background.

So you want the part with the check mark on it to be a different color? Then use this button.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse("red")) .

alt text http://www.ubuntu-pics.de/bild/22793/screenshot_009_MCxjbu.png

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM