I have written the following code
closeButton = Button(self, text="Close",command=self.askyesno)
closeButton.pack(side=RIGHT, padx=5, pady=5)
okButton = Button(self, text="OK")
okButton.pack(side=RIGHT)
def askyesno():
res = tkMessageBox.askokcancel(title="Quit", message="Do you want to quit?")
if res == "yes":
self.quit()
Whenever I press the close button, python crashes with the message Type error: askyesno() takes no arguments, 1 given. There are many examples on the Internet like mine. I'm sure they work. What am I doing wrong. All the examples I found have this problem and the documentation for tkMessageBox is not providing any examples.
It's not the tkMessageBox, it's your function. You should define it like this:
#def askyesno(): # Not like this
def askyesno(self):
Assuming it's a member of a class.