Emi*_*har 5 python tkinter messagebox python-3.x
我正在使用tkinter的"askokcancel"消息框来警告用户弹出一个不可逆转的动作.
from tkinter import Tk
Tk().withdraw()
from tkinter.messagebox import askokcancel
askokcancel("Warning", "This will delete stuff")
Run Code Online (Sandbox Code Playgroud)
我想将"确定"按钮的文本(从"确定")更改为"删除",以使其不那么温和.
这可能吗?
如果没有,实现它的另一种方法是什么?最好不要引入任何依赖...
小智 9
为什么不打开一个子窗口,从而使用您自己的按钮创建自己的框,如下所示:
from tkinter import *
def messageWindow():
win = Toplevel()
win.title('warning')
message = "This will delete stuff"
Label(win, text=message).pack()
Button(win, text='Delete', command=win.destroy).pack()
root = Tk()
Button(root, text='Bring up Message', command=messageWindow).pack()
root.mainloop()
Run Code Online (Sandbox Code Playgroud)