문제

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?

도움이 되었습니까?

해결책

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).

다른 팁

Is this what you had in mind?

import Tkinter
import tkMessageBox 

window = Tkinter.Tk()
window.option_add('*Dialog.msg.width', 50)
tkMessageBox.showinfo("header", "Hello, World!") 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top