简体   繁体   English

我正在尝试为页面制作一个退出按钮,但由于某种原因它有错误,我不知道如何解决

[英]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. askyesnotkinter.messagebox模块中定义。 Import it from there:从那里导入它:

from tkinter.messagebox import askyesno

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 由于某种原因,在我的代码中出现“索引超出范围”的错误,我实际上刚刚开始使用 Python,因此不知道如何解决这个问题 - In My Code There Is A Error Saying "Index Out Of Range" For Some Reason, I Actually Just Started Python And Hence Don't Know How To Solve This 我找到了错误的原因,但我不知道如何解决 - I found the reason for the mistake but I don't know how to solve it 我正在尝试制作 2 人 tron 游戏,但我不知道如何进行游戏开始倒计时 - I'm trying to make a 2 player tron game, and I don't know how to make a countdown to start the game 我正在尝试用 python 制作一个 bmi 计算器,但我不知道我做错了什么 - I'm trying to make a bmi calculator in python and I don't know what I'm doing wrong 我的页码显示有错误,我知道原因和位置但我不知道如何解决它们(PyQt) - My page number display has bugs, I know why and where but I don't know how to solve them (PyQt) python cPickle.PicklingError:无法腌制 <type 'instancemethod'> 我知道原因,但不知道如何解决 - python cPickle.PicklingError: Can't pickle <type 'instancemethod'> .I know the reason, but I don't know how to solve it 如何摆脱这个索引超出范围错误? 知道原因但不知道解决办法 - How to get rid of this index out of range error? I know the reason but don't know the solution 我正在尝试代码,但不知道我在某个页面上遇到错误,例如没有对象属性 - I'm trying the code and don't know i get error on somepage like no object attribute 我正在尝试结束我的程序,但我不知道该怎么做 - I'm trying to end my program but I don't know how to do it 我正在尝试获取颜色和值的每种组合,但我不知道如何使用 function islice - I'm trying to get every combination of color and value and I don't know how to use the function islice
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM