[英]I'm trying to make an exit button for the page and for some reason it has error and i don't know how to solve it
I am trying to make an exit button with the code I do import tkinter* in here我正在尝试使用我在此处导入 tkinter* 的代码创建一个退出按钮
from tkinter import*
from tkinter import ttk
from PIL import Image,ImageTk
import os
def iExit(self):
self.iExit=tkinter.askyesno("Face Recognition","Are you sure you want to exit?")
if self.iExit >0:
self.root.destroy()
else:
return
and I got the error我得到了错误
I know that I cant put tkinter
inside the code but i don't know how to solve it.我知道我不能将
tkinter
放入代码中,但我不知道如何解决它。 The error that I am getting is here我得到的错误在这里
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 1948, in __call__
return self.func(*args)
^^^^^^^^^^^^^^^^
File "c:\Users\user\Desktop\FYP\Facial_Recognition system\Main.py", line 148, in iExit
self.iExit=tkinter.askyesno("Face Recognition","Are you sure you want to exit?")
^^^^^^^
NameError: name 'tkinter' is not defined
askyesno
is defined in thetkinter.messagebox
module. askyesno
在tkinter.messagebox
模块中定义。 Import it from there:从那里导入它:
from tkinter.messagebox import askyesno
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.