#!/usr/local/cpython-3.6/bin/python3 # Example hello world program from https://developer.gnome.org/gnome-devel-demos/stable/hello-world.py.html.en # Modified by cecashon to use CSS to get around a theme problem? import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk, Gdk import sys class MyWindow(Gtk.ApplicationWindow): # constructor for a Gtk.ApplicationWindow def __init__(self, app): Gtk.Window.__init__(self, title="Welcome to GNOME", application=app) self.set_default_size(200, 100) # create a label label = Gtk.Label() # set the text of the label label.set_text("Hello GNOME!") # add the label to the window self.add(label) style_provider = Gtk.CssProvider() major_version = Gtk.get_major_version() minor_version = Gtk.get_minor_version() version_tuple = (major_version, minor_version) # DRS: I changed these to byte strings for CPython 3.x. It was probably tested on 2.x previously. # DRS: I also added the major version test. if version_tuple > (3, 20): css = b"label{color: rgba(255,0,255,1.0);}" else: css = b"GtkLabel{color: rgba(255,0,255,1.0);}" style_provider.load_from_data(css) Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), style_provider,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) class MyApplication(Gtk.Application): def __init__(self): Gtk.Application.__init__(self) def do_activate(self): win = MyWindow(self) win.show_all() def do_startup(self): Gtk.Application.do_startup(self) app = MyApplication() exit_status = app.run(sys.argv) sys.exit(exit_status)