我正在使用 Python 3 和 tkinter 编写一个程序,其中顶层最初出现在根窗口的中心。如果顶层没有移开,它会覆盖任何可能出现的显示错误消息的消息框。消息框出现在根窗口前面,但在顶层后面。命令行中的简单示例显示会发生什么:
>>> from tkinter import *
>>> from tkinter import messagebox
>>> root = Tk()
>>> texto = Toplevel(root) # (Manually put toplevel in front of root)
>>> messagebox.showinfo(message='Does this work?')
有没有办法让消息框出现在顶层前面?
我尝试使用:“parent”而不是 master 作为这个以顶层为主的消息框 https://stackoverflow.com/questions/17910866/python-3-tkinter-messagebox-with-a-toplevel-as-master这对我有用!
messagebox.showinfo("title", "message",parent=texto)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)