質問

I'm having a problem. Now I have a root window and a couple of "TopLevel's". But every time any window triggered by "tkmessagebox" gets executed, the message box appears and the root window gets sent to front. But I want it to stay at the current window.

Now, I've looked at documentation and wasn't able to find anything to prevent and or disable this using ".config".

役に立ちましたか?

解決

When a message box is dismissed, focus will be returned to the parent window. By default this is the root window. Typically you will want to set it to the button or toplevel window that caused the message box to appear.

To set the parent, use the parent attribute when creating the dialog. For example:

...
tkMessageBox.showwarning("Danger, Will Robinson!", 
                         parent=self.destruct_button)
...

See http://effbot.org/tkinterbook/tkinter-standard-dialogs.htm for more information

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top