Re: New GTK+ incompatible with old themes? How can I install new themes on an old system?

Hi Dan,

Drawing white text on a white background? Ah, I have never done that.

The different versions of GTK recognize different CSS strings. If you check the minor version of GTK when your program starts, you will know what CSS format GTK expects. For broken themes at least you should be able to use a CSS string that will work.

The themes that come with a distro will match up version wise but if the user starts changing themes outside what a distro has checked,,, problems. I haven't tried remote displays but it sounds like trouble there also.

Try adding a CSS string to your code. Maybe tweak it a little to get a fallback CSS string to work.



# Example hello world program from

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

        style_provider = Gtk.CssProvider()
            css = "label{color: rgba(255,0,255,1.0);}"
            css = "GtkLabel{color: rgba(255,0,255,1.0);}"
        Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), style_provider,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

class MyApplication(Gtk.Application):

    def __init__(self):

    def do_activate(self):
        win = MyWindow(self)

    def do_startup(self):

app = MyApplication()
exit_status =

-----Original Message-----
From: Dan Stromberg <dstromberglists gmail com>
To: ML-gtk <gtk-list gnome org>
Sent: Mon, Apr 24, 2017 3:02 pm
Subject: New GTK+ incompatible with old themes? How can I install new themes on an old system?

Hi folks.

I'm attempting to run a "hello world" application copied from .  I did change it, but only minimally - specifically, I added a #!, and gave it a gi.require_version('Gtk', '3.0')

It runs fine displayed on a Linux Mint 18.1 system (as long as I don't monkey with the themes - trying to change themes using lxappearance breaks it).  It doesn't appear to run well displayed on a Linux Mint 18 system.

I used lxappearance to change themes.  I'm getting the feeling that either this was a mistake, or the version of lxappearance I'm using is too old.  I'm not using LXDE as my desktop, BTW, I'm using a mix of Cinnamon and fvwm2.

Some relevant files are in:

More specifically, at that svn URL:
* is the slightly modified hello world app from the gnome demos URL mentioned above.
* good.png is a screenshot of what the app looks like when things are going well (displayed on a Mint 18.1 system without having used lxappearance).
* bad.png is what the app looks like when things are not going well (displayed on a Mint 18 system, or a Mint 18.1 system on which I've tried to change themes using lxappearance).

Is there a good way of running a new GTK+ app remote displayed to a system with an old theme, or of running an old app remote displayed to a system with a new theme?  Do I just need to upgrade the old themes to something modern? And what tool should I do the theme upgrade with, if any?

I googled a bit, but it looks like a lot of the information around the internet on this topic is dated now.  If there's a manual or FAQ list I should look at, feel free to point me at it/them.


gtk-list mailing list
gtk-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]