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

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 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败