gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 13:58:49 25 4
gpt4 key购买 nike

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

    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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com