【问题标题】:Python 3 tkinter message box highlight the "No" button?Python 3 tkinter 消息框突出显示“否”按钮?
【发布时间】:2018-08-12 00:47:48
【问题描述】:

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

    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 python-3.x tkinter messagebox


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢先生,请问您知道如何将高光的颜色从蓝色更改为“红色”吗?有可能吗?
    • 不客气。恐怕我不知道;我认为 tkinter 正在将您的系统设置用于对话框,但不会让您访问您想要的控制级别。
    猜你喜欢
    • 2015-09-27
    • 2015-11-15
    • 1970-01-01
    • 1970-01-01
    • 2016-11-06
    • 1970-01-01
    • 1970-01-01
    • 2020-10-07
    • 2020-06-15
    相关资源
    最近更新 更多