Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6146657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:58:58+00:00 2026-05-23T18:58:58+00:00

With introduction of GObject introspection the way to access theme colors through widget.get_style() method

  • 0

With introduction of GObject introspection the way to access theme colors through widget.get_style() method is gone. I am interested on how to get theme colors when GTK+ is used through GOBject introspection. The solution should preferably work with both versions (2 and 3) but a solution for each of these is acceptable as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:58:59+00:00Added an answer on May 23, 2026 at 6:58 pm

    I’m not sure how to get it from gtk+-2.0, unless your using a pure gtk+-2.0 environment, in which case I think the old GtkStyle methods work. for example, assuming your not running a Gtk-3.0 environment like gnome-shell

    import gi
    # make sure you use gtk+-2.0
    gi.require_version('Gtk', '2.0')
    from gi.repository import Gtk
    
    window = Gtk.Window()
    
    ...
    
    style = window.get_style()
    print style.lookup_color('fg_color')
    

    I think that should still work under a gtk+-2.0 environment. I don’t know for sure as my system is running gnome-shell, and can’t easily try this out.

    However this method has been deprecated and replaced by GtkStyleContext. If I use the above code in a gtk+-3.0 environment like gnome-shell it will run, but does not give me the information I’m after. What I get is

    (False, <Gdk.Color(red=0, green=0, blue=0)>)
    

    EDIT: Looking back at this, I think the above is still giving the correct info. The colour for fg_color is not found, as indicated by the first entry in the tuple result, which is False. Also the window must be visible for the colours to be found.

    If I want colour information I want to use the new GtkStyleContext, for example

    import gi
    # make sure you use gtk+-3.0
    gi.require_version('Gtk', '3.0')
    from gi.repository import Gtk
    
    window = Gtk.Window()
    
    ...
    
    style_context = window.get_style_context()
    print style_context.lookup_color('fg_color')
    

    this will give me some real data, which is telling me the ‘fg_color’ has been found, due to the first entry in the tuple is True.

    (True, <Gdk.Color(red=0.000000, green=0.000000, blue=0.000000, alpha=1.000000)>)
    

    I hope this answers your question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Introduction I can't seem to get the the ChartObjects.CopyPicture method to work in Excel
Introduction I've always been searching for a way to make Visual Studio draw a
INTRODUCTION I'm using excel downloads as a way of users downloading a score sheet,
Introduction: I'm trying to get additional fields to log with log4j, and its working
Introduction: I want to loop through XML files with flexible categories structure. Problem: I
Introduction I have some sort of values that I might want to access several
Introduction I'm relatively new to C++. I went through all the basic stuff and
Introduction : Hello Everyone, I have been looking for days for a way to
By way of introduction... I've run into this question: Difference between 2 adjacent fields
Introduction I am planning to create a widget much like, Facebook provides for likes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.