SosoDefficult 2016-04-26 15:12 采纳率: 0%
浏览 3638
已结题

Python新手的一个问题

写一个登陆的界面,账号密码对了就会出现一个标签,但是e2['show']='*' ,这句话报错,错误的提示是TypeError: 'NoneType' object does not support item assignment

贴出代码如下

-*- coding:utf-8 -*-

from Tkinter import *

def reg():
s1=e1.get()
s2=e2.get()
t1=len(s1)
t2=len(s2)
if s1=="1111" and s2=="2222":
c["text"]="登陆成功"
else:
c["text"]="登陆失败"
e1.delete(0,t1)
e2.delete(0,t2)

root= Tk()
root.wm_title("登陆界面")
l=Label(root,text="用户名: ")
l.grid(row=0,column=0,sticky=W)

e1=Entry(root)
e1.grid(row=0,column=1,sticky=E)

l2=Label(root,text="密码: ").grid(row=1,column=0,sticky=W)
e2=Entry(root).grid(row=1,column=1,sticky=E)
e2["show"] = '*'

b=Button(root,text="登陆",command=reg).grid(row=2,column=1,sticky=E)

c=Label(root,text=" ")
c.grid(row=3)
root.mainloop()

  • 写回答

6条回答

  • threenewbee 2016-04-26 15:19
    关注

    e2["show"]
    这个show在哪里写的。

    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办