2

10I'm trying to make use of GTK3+ on Windows. The setup is Python 2.7 and GTK3+ (3.10.x) installed from http://sourceforge.net/projects/pygobjectwin32/files/?source=navbar Which to me seemed like the easiest way to get it up and running, correct me if I'm wrong.

The following app works fine on Linux but on Windows the shading of the button is off and I cannot seem to change the color of the text, it just stays black.

from gi.repository import Gtk, Gdk

win = Gtk.Window()
win.set_name('MyWindow')

# The Button
button = Gtk.Button("Click Me")
win.add(button)


win.connect("delete-event", Gtk.main_quit)

style_provider = Gtk.CssProvider()

css = """
#MyWindow GtkButton {

    border-radius: 10px;
    border-color: #000;
    font: Sans 10;
    color: white;                   
    box-shadow: 0 0 5px grey inset;
    margin: 10px;
}
"""

style_provider.load_from_data(css)

Gtk.StyleContext.add_provider_for_screen(
    Gdk.Screen.get_default(), 
    style_provider,     
    Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)

win.show_all()
Gtk.main()

Any ideas about what could be wrong here?

3
  • I believe Gtk is using a specific engine on Windows for theming, so that Gtk apps integrate properly to native UIs. IIRC, this engine does not accept all CSS properties, like linux engines do. Commented Jan 7, 2014 at 17:18
  • Forget that, Gtk3 theme for Windows should be pure CSS, not engine dependent: blogs.gnome.org/alexl/2011/11/25/gtk-work-on-windows Commented Jan 7, 2014 at 17:32
  • Well that's good news though I wonder whats wrong here, did i not install it correctly? Commented Jan 7, 2014 at 18:58

1 Answer 1

3

make sure that in your settings.ini the theme Adwaita is not commented out, you can find it in C:\Python27\Lib\site-packages\gnome\etc\gtk-3.0 (or similar prefix depending on your installation of python)

[Settings]
gtk-theme-name = Adwaita
#gtk-font-name = Arial 10
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.