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.

Eric

#!/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

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()
        minor_version=Gtk.get_minor_version()
        if(minor_version>20):
            css = "label{color: rgba(255,0,255,1.0);}"
        else:
            css = "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)


 

 

-----Original Message-----
From: Dan Stromberg <dstrombergli...@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 
https://developer.gnome.org/gnome-devel-demos/stable/hello-world.py.html.en .  
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:
http://stromberg.dnsalias.org/svn/gi-hello/trunk



More specifically, at that svn URL:
* hello.py 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.


Thanks!



_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list

_______________________________________________
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list

Reply via email to