Canvas create_text() 的版本支持自动换行吗?

发布于 2024-10-01 06:09:06 字数 297 浏览 1 评论 0原文

是否有支持自动换行的 create_text() 模式或技术?我无法使用 create_text()LabelText 小部件,因为我将文本放置在画布上的图像顶部。

另外,是否有一个 Tkinter API 可以使用省略号之类的后缀截断不适合特定宽度的文本,例如。 Where very, very, very long text 被转换为类似 Where very, very, ... 的内容。

Is there a create_text() mode or technique that supports word wrap? I'm stuck using create_text() vs. a Label or Text widget because I'm placing text on top of an image on my Canvas.

Also, is there a Tkinter API that truncates text that doesn't fit a certain width with an ellipsis like suffix, eg. Where very, very, very long text gets converted to something like Where very, very, ....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

箹锭⒈辈孓 2024-10-08 06:09:06

create_text() 中确实有自动换行功能。您可以这样称呼它:

canvas.create_text(x, y, width=80)

您可以将宽度参数设置为您想要的任何最大长度,或者如果您不希望自动换行,则将其设置为 0。请参阅本文,了解 <代码>create_text()。

我不确定截断文本,但我确实看到这个 谈论限制 Entry 小部件中输入长度的方法...

There is indeed a word wrap feature in create_text(). You'd call it like so:

canvas.create_text(x, y, width=80)

You can set the width parameter to whatever max length you want, or 0 if you want no word wrapping. See this article for all the options, arguments etc. for create_text().

I'm not sure about truncating text, but I did see this talking about a way to limit the length of input in an Entry widget...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文