I have recently started using pygtk/PyGObject and have been trying to apply or change the background color or a simple button or any other widget using the following line of code obtained from one of the QA here.
self.button.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0.0, 1.0, 0.0, 1.0))
But that does not seem to apply or work.
The whole sample test program is here.
#!/usr/bin/env python
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
class MyWIndow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.button = Gtk.Button(label="Click")
self.button.override_background_color(Gtk.StateFlags.NORMAL, Gdk.RGBA(0.0, 1.0, 0.0, 1.0))
self.button.connect("clicked", self.on_button_clicked)
self.add(self.button)
def on_button_clicked(self, widget):
Gtk.main_quit()
win = MyWIndow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
Is there anything that I am missing? Thanks in advance.