如何在 tkinter 中设置字体大小以适合框架的特定宽度
实际上,我正在python的Tkinter的帮助放入。我希望我只是给出一个字符串,它将根据宽度自动调整字体的大小。 例如: - 让我提供一根“ Raj Kundra酒店和家庭餐厅”的字符串,让框架/标签的宽度为500。 因此,它将如何自动在这种窗口的大小上自动调整,而不会包装文本。只需适合窗口尺寸
actually I am making a project with the help of tkinter in python so basically I want to shrink my font size of a label according to the width of the frame that it will be put in. I want that just i am giving a string and it will automatically adjust the size of the font according to the width.
For an Example:- Let I am Giving a String that is " Hotel Raj Kundra and Family Resturant", let the width of the Frame/label is 500.
so how it will automatically adjust in this size of window without wrapped the text. just fit in the window size
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 .config,您可以在放置后调整属性。
现在您可以使用字符串的 len() 调整窗口大小。
我希望它有帮助。
with .config you can adjust Attributes after you placed it.
Now you can adjust the window size with the len() of your string.
I hope it helps.
更简单的方法:
结果最宽:
缩小结果:
Easier way to do this:
Result widest:
Result to shrink: