Python Forum
How can I get Colors of current GTK theme?
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I get Colors of current GTK theme?
#3
thanks!
(May-25-2017, 05:26 PM)Larz60+ Wrote: (using pygtk and package)
afaiu pygtk is python2 and works only with gtk2.
if you look at post #1, that's what i used to implement the gtk2 solution.

for gtk3, this:
Quote:http://python.6.x6.nabble.com/GTK3-get-b...03859.html
is a little closer to what I want.

i can now get some information about gtk colors without showing a window:
#!/usr/bin/env python

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

def on_button_clicked(button, tv):
    style = tv.get_style_context()
    bgcolor = style.get_background_color(Gtk.StateType.NORMAL) 
    print(bgcolor) 

win = Gtk.Window()
vb = Gtk.VBox()
tv = Gtk.TextView()
vb.add(tv)
win.show_all()
style = tv.get_style_context()
bgcolor = style.get_background_color(Gtk.StateType.NORMAL) 
print(bgcolor)
#settings = Gtk.Settings.get_default()
#for i in settings.list_properties():
#    print(i)
this will give me reasonable color values:
Output:
Gdk.RGBA(red=0.866667, green=0.866667, blue=0.866667, alpha=1.000000)
halfway there.

if i uncomment the last 3 lines i also get a long list of gtk3 properties; but i
- don't know how to get at the values
- don't know if they're even filled with current values.

any help appreciated.

o.
Reply


Messages In This Thread
RE: How can I get Colors of current GTK theme? - by ondoho - May-26-2017, 03:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to get RGB colors in tkinter menator01 3 10,636 May-02-2020, 10:47 PM
Last Post: Larz60+
  [Tkinter] Theme does not change globally TheTechRobo 2 3,460 Apr-21-2020, 04:00 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020