新建文件,运行界面要求如下: 1假定用户名为“admin”,密码为“123456”,如果用户名和密码正确,显示如下界面。2如果用户名或密码不正确,显示如下界面。3单击“重填”按钮,清空两个输入框

思路:…模仿的,以后再加上去

from tkinter import *
from tkinter import messagebox as msgbox

root = Tk()
root.minsize(300, 200)
root.title("登陆窗口")


def login():
    if s1.get() == "admin" and s2.get() == "123456":
        msgbox.showinfo("恭喜", " 登录成功")
    else:
        msgbox.showerror("警告", "用户名或密码错误")
        s1.set("")
        s2.set("")


def re():
    s1.set("")
    s2.set("")


Label(root, text="输入用户名:").place(x=50, y=40)
Label(root, text="  输入密码:").place(x=54, y=70)
s1 = StringVar()
s2 = StringVar()
Entry(root, textvariable=s1, width=14).place(x=120, y=40)
Entry(root, textvariable=s2, width=14, show="*").place(x=120, y=70)
Button1 = Button(root, text="登录", width=5, command=login).place(x=80, y=120)
Button2 = Button(root, text="重填", width=5,command=re).place(x=140, y=120)
mainloop()
  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值