简单的登陆页面调计 python

from tkinter import *
from tkinter import messagebox

class Application(Frame):

def __init__(self, master=None):
    super().__init__(master)
    self.master = master
    self.pack()
    self.creatWidget()

def creatWidget(self):
    Label(self, text="用户名").pack()
    # 用户名
    var_user_name = StringVar()
    self.entry_user_name = Entry(self, textvariable=var_user_name)
    self.entry_user_name.pack()
    var_user_name.set("admin")

    Label(self, text="密码").pack()
    # 密码
    var_user_pwd = StringVar()
    self.entry_user_pwd = Entry(self, textvariable=var_user_pwd, show="*")
    self.entry_user_pwd.pack()
    btn1 = Button(self, text="登陆", command=self.songhua)
    btn1.pack()

def songhua(self):
    username = self.entry_user_name.get()
    pwd = self.entry_user_pwd.get()
    print("用户名:", username)
    print("密码:", pwd)
    if username == "jiangjun" and pwd == "123456":
        messagebox.showinfo(" ", "登陆成功,欢迎使用")
    else:
        messagebox.showinfo(" ", "登陆失败,请重新输入")

windows = Tk()
windows.geometry(“400x300+800+300”)
windows.title(“一个经典的GUI”)
app = Application(master=windows)
windows.mainloop()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值