Python 3 tkinter 消息框突出显示 "No"按钮?

标签 python python-3.x tkinter messagebox

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

    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

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

something like this

最佳答案

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

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

关于Python 3 tkinter 消息框突出显示 "No"按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51804862/

相关文章:

Python Selenium(等待框架、元素查找)

python-3.x - 从Python中的字符串中删除特殊字符

python asyncio解释和信号处理程序

python - 检查两个大型名称和版本列表中的版本更新

python - 如何让 Bind 和 Command 在 tkinter 中做同样的事情?

Python py2exe 窗口显示 (tkinter)

python - scikit-learn 多维特征

python - 类型错误 : include and exclude must both be non-string sequences

python - 使用 MySQLdb 执行多个 SQL 查询

python3.4 tkinter.scrolledtext 不可调用