How do I adapt the look and feel of existing Tk apps using TTk?

折月煮酒 提交于 2019-12-13 03:37:34

问题


slebetman says:

But Tk is only really ugly on Unixen because it defaults to a Motif theme (modern Tk is/should be replaced by TTk which is themeable).

Given two Tk apps which I still use occasionally, namely Gitk and ptkdb, how do I change their look and feel so that it matches the rest of the desktop environment (KDE 4)?


回答1:


See: http://wiki.tcl.tk/gtklook.tcl for a quick way to make default Tk look less painfully ugly. I often use it in my own programs to hide the fact that it's actually written in tcl/tk.

The code given is tcl but you can easily use the options in an Xresources or Xdefaults file which I think should work in other languages as well. Or, it that doesn't work I believe there is an equivalent option method in Perl/Tk*.

Yes, the changes are not much. Basically just reducing pixel widths of things like borders and scrollbars. But it does look much nicer.

*note: I only mention Perl/Tk because you mentioned it in another post. As for modifying gitk, it is written in tcl so you can easily copy-paste the code somewhere.




回答2:


Check out the TkDocs website, everything I know about modern Tk I learnt from there! Well and experience too of course ;-)

It will not be simple to retrofit it onto a substantial legacy application, but you could probably get surprisingly far by just prefixing the widgets with ttk::.



来源:https://stackoverflow.com/questions/3838368/how-do-i-adapt-the-look-and-feel-of-existing-tk-apps-using-ttk

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