Python and tkinter: NameError: name 'askyesno' is not defined

872 views Asked by At

I get this error:

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python36-32\lib\tkinter\__init__.py", line 1699, in __call__ return self.func(*args)
File "C:\Users\Administrator\Desktop\Base\utility.py", line 68, in clear
askyesno('Clear', 'Press YES or NO')
NameError: name 'askyesno' is not defined

When I try to run this:

if askyesno('Clear', 'Press YES or NO'):
 do some code

I have tried tkMessageBox.askyesno but still getting the error.

1

There are 1 answers

0
Rarblack On BEST ANSWER

Try this from tkinter import messagebox to import messagebox and then:

 if messagebox.askyesno('Clear', 'Press YES or NO'):