Get colors of current gtk style

时间秒杀一切 提交于 2019-12-01 08:22:15

I just stumbled upon the same issue, saw your question and found a solution: You have to wait until the widget is realized, e.g. like this:

def print_style(widget):
    style = widget.get_style()
    for i in range(5):
        print i, gdkColorToRgb(style.bg[i])
gdkColorToRgb = lambda gc: (gc.red//257, gc.green//257, gc.blue//257)
widget = gtk.HBox() ## for example
widget.connect('realize', print_style)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!