python - 如何将 tkinter 中的 Entry 小部件的结果文本设置为斜体?

标签 python tkinter tkinter-entry text-formatting italic

因此可以使用 .get 方法检索 Entry 小部件的文本,但我的问题是: 您可以将 .get 从小部件接收到的文本设置为斜体吗?

font 参数添加到 Entry 只会更改 Entry 中显示的文本,而不更改 .get 为您提供的实际输出,所以我不知所措.

我实际上试图通过这样做来实现的是仅将条目字段的文本的特定部分/字符串斜体化,同时保持文本的其他部分统一,所以如果您有任何这样做的提示,我将不胜感激的帮助!

提前感谢您的建议!

最佳答案

What I'm actually trying to accomplish by doing this is italicizing only a certain part/string of the text of an Entry field while keeping the other parts of the text unitalicized,

那是不可能的。 Entry 小部件只能以单一字体显示文本。

如果您想要使用多种字体,则需要使用“文本”或“ Canvas ”小部件,其中“文本”小部件是最简单的解决方案。

关于python - 如何将 tkinter 中的 Entry 小部件的结果文本设置为斜体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59711487/

相关文章:

python - 检查列表中是否存在具有特定值的字典

python - 结束 ssh session 后在后台运行 python/matplotlib 的问题

python - 如何在类的 __init__ 函数中使用 Canvas 参数?

python - pygame:获取音乐的当前时间

python - 有没有办法在 tkinter 中使用字符串作为输入框的变量名?

python - 通过 Cython 转换为 Python 的基本 C++ 函数

python - 按形状和大小分类

python - 从按钮将数据输入到 Entry 小部件

python - 如何修复 "elasticsearch.exceptions.AuthenticationException: ... missing authentication token for REST request"?

python - IP 地址的 Tkinter 条目验证