Change tkMessageBox "askyesno" button names

Question:

How can I change button names of tkMessagebox.askyesno function?

Exactly I want to change yes-button text yes with other and no-button text too

Asked By: godot

||

Answers:

You can’t just simply modify the button text. You need to create a custom dialog. For example (taken from http://tkinter.programujte.com/tkinter-dialog-windows.htm):

from Tkinter import *

class MyDialog:

    def __init__(self, parent):

        top = self.top = Toplevel(parent)

        Label(top, text="Value").pack()

        self.e = Entry(top)
        self.e.pack(padx=5)

        b = Button(top, text="OK", command=self.ok)
        b.pack(pady=5)

    def ok(self):

        print "value is", self.e.get()

        self.top.destroy()


root = Tk()
Button(root, text="Hello!").pack()
root.update()

d = MyDialog(root)

root.wait_window(d.top)
Answered By: Selcuk
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.