Search code examples
tcltk-toolkittkmessageboxmessagedialog

How to set the size of 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?


Solution

  • 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 the toplevel 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).