在Tkinter中真正的自定义字体 [英] Truly custom font in Tkinter

查看:630
本文介绍了在Tkinter中真正的自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Tkinter中创建一个接口,我需要自定义字体。不仅仅是,比如Helvetica在某个特定的大小或任何其他地方,而是在任何给定的平台上通常可用的字体。这将是与该程序一起保存的图像文件或(最好)Truetype字体文件或类似的东西。我不想在所有要使用该程序的计算机上安装所需的字体,我只是想将它们放在同一目录中的程序中。



tkFont模块看起来应该像这样做,但是我看不到在哪里需要一个文件名,这个文件对于运行程序的系统来说通常是不可访问的。
提前感谢您的帮助。

解决方案

我找到这个讨论,他们讨论了如何使用一行文本作为图像并使用PIL来放置它进入窗口。这可能是一个解决方案。



我找不到使用tkFont在 tkFont手册页


I am making an interface in Tkinter and I need to have custom fonts. Not just, say, Helvetica at a certain size or whatever, but fonts other than what would normally be available on any given platform. This would be something that would be kept with the program as an image file or (preferably) Truetype font file or similar. I don't want to have to install the desired fonts on every machine that is going to use the program, I just want to carry them around with the program in the same directory.

The tkFont module looks like it ought to do something like this, but I can't see where it would take a filename for a font not normally accessible to the system running the program. Thanks in advance for your help.

解决方案

I found this discussion where they cover how to use a line of text as an image and use PIL to place it into the window. That might be a solution.

I could not find a way to use tkFont to import a bundled font in the tkFont man page.

这篇关于在Tkinter中真正的自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆