Is there a way to change the current PyGTK theme on Windows?

偶尔善良 提交于 2019-12-12 09:03:09

问题


I've written a Python app that uses PyGTK. It runs fine on Linux and looks great. It also runs fine on Windows, but it looks absolutely awful. The default GTK theme looks absolutely nothing like the native Windows GUI elements.

Is there anything I can do to make my Python app look a little better? Perhaps some function I can call to change to theme to something a little nicer?


Edit: using the rc_parse() function suggested in the answer below, I now have:

import pygtk,gtk

gtk.rc_parse("C:\\Program Files\\Common Files\\GTK\\2.0\\share\\themes\\Bluecurve\\gtk-2.0\\gtkrc")

window = gtk.Window(gtk.WINDOW_TOPLEVEL)
button = gtk.Button()
button.set_label("Hello")

window.add(button)

button.show()
window.show()

gtk.main()

...but it's not working.


回答1:


I believe you're looking for the rc_parse function, which will let you load a gtkrc file with a theme. Also, see http://faq.pygtk.org/index.py?file=faq21.012.htp&req=show, which shows how to change the GTK theme on windows. Now the problem becomes finding a GTK theme that fits your needs. Some googling turns up http://gtk-wimp.sourceforge.net/, which may be what you need.




回答2:


I would look into gtk-wimp.




回答3:


You have to install the matching theme engine in Windows or use a gtk-wimp theme which is on Windows by default. Bluecurve requires the bluecurve engine. See http://faq.pygtk.org/index.py?file=faq21.012.htp&req=show




回答4:


Try this after the reparse, to change the style:

gtk.rc_reset_styles(gtk.settings_get_for_screen(self.window.get_screen()))


来源:https://stackoverflow.com/questions/5768265/is-there-a-way-to-change-the-current-pygtk-theme-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!