私は次のコードを書きました
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()
閉じるボタンを押すたびに、Python がクラッシュし、Type error: askyesno() takes no arguments, 1 given というメッセージが表示されます。私のような例はインターネット上にたくさんあります。私は彼らが働くと確信しています。私は何を間違っていますか。私が見つけたすべての例にはこの問題があり、tkMessageBox のドキュメントには例がありません。