Python 3 tkinter消息框突出显示“否”按钮?

我想创建一个确认删除意图的消息框.

    def delete_action(self):
    s_id = self.selected_ID_entry.get()
    s_name = self.seletedEntry.get()
    answer = messagebox.askquestion("Delete?","Are you sure you want to delete {}".format(s_name), icon='warning')

    if answer == 'yes':
        #deleted function here
    else:
        #not deleted function here

如何突出显示“否”按钮而不是“是”按钮?

Python 3 tkinter消息框突出显示“否”按钮?

解决方法:

您可以将默认值设置为关键字参数;这样的事情:

import tkinter as tk
from tkinter import messagebox

def quid():
    messagebox.askyesno("What", "What???????????", default='no')

root = tk.Tk()
ask = tk.Button(root, text='what?', command=quid)
ask.pack()
root.mainloop()
上一篇:[转载] C++ 编写对话框/提示框的方法


下一篇:基于MFC的网络编程(远程桌面监控)学习笔记(二)发消息