Como fazer botões de cores diferentes no Python GTK3 (usando gi)?

Meu mais recente head-scratcher é construir um pequeno aplicativo bobo no Python3 usando o GTK3, com cores diferentes de cinza-claro nos botões. Eu passei os últimos dias pesquisando como fazer isso, e até agora tudo que eu tentei falhou. Não apenas falhou, mas falhousilenciosamente, sem mensagens de erro para me dar qualquer pista sobre o que está acontecendo.

Este é o meu aplicativo de teste:

from gi.repository import Gtk, Gdk

class ButtonWindow(Gtk.Window):

    def __init__(self):
        super().__init__(title="Button Test")
        self.set_border_width(10)
        hbox = Gtk.Box(spacing=10)
        self.add(hbox)
        hbox.set_homogeneous(False)

        # make the button
        button = Gtk.Button('Test Button')
        hbox.pack_start(button, True, True, 0)

        # try to change its colour ....

#        button.modify_base(Gtk.StateType.NORMAL, Gdk.color_parse('green'))
#        button.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(0, 1, 0, 1))
#        button.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(0x00ff00))
#        button.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse("green"))
#        button.modify_bg(Gtk.StateType.ACTIVE, Gdk.color_parse("green"))
#        button.modify_bg(Gtk.StateType.SELECTED, Gdk.color_parse("green"))

        # attempt to change the style ....

#        style = button.get_style().copy()
#        style.bg[Gtk.StateType.NORMAL] = Gdk.color_parse('green')
#        style.bg[Gtk.StateType.ACTIVE] = Gdk.color_parse('red')
#        style.bg[Gtk.StateType.SELECTED] = Gdk.color_parse('blue')
#        style.bg[Gtk.StateType.PRELIGHT] = Gdk.color_parse('black')
#        button.set_style(style)

        # ok, let's try changing the box ....

#        hbox.modify_base(Gtk.StateType.NORMAL, Gdk.color_parse('green'))
#        hbox.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(0,1,0,1))
#        hbox.override_background_color(Gtk.StateType.NORMAL, Gdk.RGBA(0x00ff00ff))
#        hbox.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('green'))

window = ButtonWindow()        
window.connect("delete-event", Gtk.main_quit)
window.show_all()
Gtk.main()

Eu deixei minhas tentativas fracassadas como comentários. Como observado acima, no que diz respeito ao aplicativo, parece ter funcionado, porque nenhuma das variações acima gera quaisquer mensagens de erro. Contudo,Nenhum deles parecem funcionar para mim, porque os botões permanecem da cor da água parada.

FYI Eu estou usando o Python 3.2.3 no Ubuntu 12.04 com python3-gi e python3-gi-cairo instalado a partir do repositório padrão.

Alguém pode, por favor, apontar a direção certa?

EDIT: O seguinte é um exemplo re-trabalhado com base na resposta do @ mike. Isso funciona, mas há alguns problemas com isso, possivelmente para serem abordados em algumas perguntas de acompanhamento. Os problemas são:

Porquebackground tem que usado no Ubuntu em vez debackground-colore, em seguida, apenas para o botão?Eu ainda tenho alguns problemas para obter o estilo de fonte para funcionar, mas pelo menos agora eu tenho um exemplo de trabalho para brincar.Podem ser aplicados diferentes estilos / cores a diferentes botões, por ex. com base no texto ou algum outro atributo?

Então, o código: -

from gi.repository import Gtk, Gdk

class ButtonWindow(Gtk.Window):

    def __init__(self):
        super().__init__(title="Button Test")
        self.set_border_width(10)

        hbox = Gtk.Box(spacing=10)
        self.add(hbox)
        hbox.set_homogeneous(False)

        # make the button
        button = Gtk.Button('Test Button')
        hbox.pack_start(button, True, True, 0)

# get the style from the css file and apply it
cssProvider = Gtk.CssProvider()
cssProvider.load_from_path('gtkStyledButtonTest.css')
screen = Gdk.Screen.get_default()
styleContext = Gtk.StyleContext()
styleContext.add_provider_for_screen(screen, cssProvider,
                                     Gtk.STYLE_PROVIDER_PRIORITY_USER)

window = ButtonWindow()        
window.connect("delete-event", Gtk.main_quit)
window.show_all()
Gtk.main()

e o arquivo css se parece com isso:

GtkWindow {
    background-color: #0000ff;
}

GtkButton {
    color: #ff0000;
    background: #00ff00;
}

Espero que alguém ache isso útil.

questionAnswers(3)

yourAnswerToTheQuestion