Perl TK 调整窗口大小
是否可以自动将 Tk 窗口的大小调整为文本图中文本的宽度和高度?
Is it possible to automatically resize a Tk window to the width and height of the text inside of the text plot?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以轻松测量特定字体中某些文本的宽度:
为边框等添加一点倾斜,并使用它来设置顶层的大小:
如果它不是您想要控制的顶层,这是最简单的通过将内容放入框架中并控制该框架的大小来实现此目的(相同的方法,相同的选项)。另请注意,如果行太多或太长,则无论如何它都无法适合屏幕。
You can easily measure how wide some text is in a particular font:
Add in a bit of slop for borders, etc., and use this to set the size of the toplevel:
If it's not a toplevel that you want to control, it's easiest to do this by putting the contents in a frame and controlling the size of that frame (same method, same options). Also be aware that if you have too many rows or too long lines, it won't fit on the screen anyway.