会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133689个问题
Python 全系列/第六阶段:数据库与AI协同技术实战/mysql的使用 31744楼
WEB前端全系列/第二阶段:JavaScript编程模块/函数与对象 31745楼
Python 全系列/第十六阶段:Python 爬虫开发/scrapy框架使用(旧) 31746楼

from tkinter import *
from tkinter import messagebox

class Application(Frame):
    def __init__(self,master=None):
        super().__init__(master)
        self.master = master
        self.pack()
        self.create()
    def create(self):
        self.label01 = Label(self,text="用户名").pack()
        v1 = StringVar()
        self.entry01 = Entry(self,textvariable=v1).pack()
        self.label02 = Label(self, text="密码").pack()
        v1.set("admin")
        v2 = StringVar()
        self.entry02 = Entry(self, textvariable=v2,show="*").pack()
        self.btn01 = Button(self, text="登录", command=self.b).pack()


    def b(self):
        username = self.entry01.get()
        password = self.entry02.get()
        if username == "haha" and password == 123456:
            messagebox.showinfo("登录成功")
        else:
            messagebox.showinfo("登录失败")
if __name__ == "__main__":
    root = Tk()
    root.title("今日的练习")
    root.geometry("400x400+200+200")
    app = Application(master=root)
    root.mainloop()



Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\zhangzhen\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
    return self.func(*args)
  File "C:/Users/zhangzhen/PycharmProjects/zhanghzen/haha.py", line 22, in b
    username = self.entry01.get()
AttributeError: 'NoneType' object has no attribute 'get'

get为什么没有?

Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 31747楼
JAVA 全系列/第六阶段:JavaWeb开发/Ajax技术详解(旧) 31748楼
JAVA 全系列/第六阶段:JavaWeb开发/Ajax技术详解(旧) 31750楼

flask项目.zip

老师,我用的是pycharm,
代码可以运行,但是结果错误,找不到相应的网页,说我输入错误


Python 全系列/第九阶段:Flask百战电商后台系统/Flask百战电商后台项目 31752楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 31753楼
Python 全系列/第十六阶段:Python 爬虫开发/爬虫反反爬- 31755楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637