如何设置tk_messageBox的大小?
我正在使用带有大量消息的 tk_messageBox,因此我想配置该消息对话框的布局。
我像这样使用 tk_messageBox:
set status [tk_messageBox -type yesno -icon warning -message "Here goes a text with 50 words"]
How can I set the width and height of tk_messageBox here?
也许 tk_messageBox 有一些更好的替代品?
I am using a tk_messageBox
with a lage message, so I would like to configure the layout of that message dialog.
I am using tk_messageBox
like this:
set status [tk_messageBox -type yesno -icon warning -message "Here goes a text with 50 words"]
How can I set the width and height of tk_messageBox
here?
Maybe there are some better alternatives for tk_messageBox
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您无法设置
tk_messageBox
的大小(该功能与这些对话框在 Windows 和 OSX 上的工作方式不符)。您可以尝试将一些消息放入-detail
选项中,该选项通常使用较小的字体。或者,您可以尝试在 Tk 安装的文件
msgbox.tcl
中查找在 Unix/X11 上实现消息框对话框的 Tcl 代码。提示:仅在该平台上,tk_messageBox
实际上是::tk::MessageBox
的别名。该脚本创建的小部件的名称取决于-parent
选项,但如果该选项不存在,则为.__tk__messagebox
。知道了这一点,您应该能够使用巧妙的事件处理来配置相关的toplevel
小部件。但这不是一个好的解决方案,并且在 Windows 或 OSX 上都不起作用(当为 Aqua 而不是 X11 构建时)。You can't set the size of a
tk_messageBox
(that's functionality which doesn't fit with the way those dialogs work on Windows and OSX). You can try putting some of the message into the-detail
option, which usually uses a smaller font.Or you can try looking in the file
msgbox.tcl
of your Tk installation for the Tcl code that implements the message box dialog on Unix/X11. Hint: on that platform only,tk_messageBox
is really an alias for::tk::MessageBox
. The name of the widget created by that script depends on the-parent
option, but if that's absent, it's.__tk__messagebox
. Knowing that, you should be able to use clever event handling to configure thetoplevel
widget in question. But this is not a nice solution, and won't work on either Windows or OSX (when build for Aqua instead of X11).这就是你的想法吗?
Is this what you had in mind?
.option_add
可能仅适用于 Linux 操作系统,但您可以控制字体、换行位置以及框的宽度:(其中“6i”是行的长度,以英寸为单位)
.option_add
may only work for linux operating systems, but you can control font, where the lines wrap, and the width of the box:(where "6i" is the length of the line in inches)
我使用这些设置,但没有在X11以外的其他平台上测试过。
当然你可以尝试除10c(代表10厘米)以外的其他尺寸。
I use these settings, but haven't tested on other platforms beside X11
Of course you can try other sizes than 10c (which stands for 10 centimeters).