如下所示:

from tkinter import *
 
class Reg (Frame):
  def __init__(self,master):
    frame = Frame(master)
    frame.pack()
    self.lab1 = Label(frame,text = "账户:")
    self.lab1.grid(row = 0,column = 0,sticky = W)
    self.ent1 = Entry(frame)
    self.ent1.grid(row = 0,column = 1,sticky = W)
    self.lab2 = Label(frame,text = "密码:")
    self.lab2.grid(row = 1,column = 0)
    self.ent2 = Entry(frame,show = "*")
    self.ent2.grid(row = 1,column = 1,sticky = W)
    self.button = Button(frame,text = "登录",command = self.Submit)
    self.button.grid(row = 2,column = 1,sticky = E)
    self.lab3 = Label(frame,text = "")
    self.lab3.grid(row = 3,column = 0,sticky = W)
    self.button2 = Button(frame,text = "退出",command = frame.quit)
    self.button2.grid(row = 3,column = 3,sticky = E)
  def Submit(self):
    s1 = self.ent1.get()
    s2 = self.ent2.get()
    if s1 == 'admin' and s2 == '123':
      self.lab3["text"] = "登陆成功"
    else:
      self.lab3["text"] = "用户名或密码错误!"
    self.ent1.delete(0,len(s1))
    self.ent2.delete(0,len(s2))
root = Tk()
root.title("用户登录")
app = Reg(root)
root.mainloop()

Python Tkinter 简单登录界面的实现

以上这篇Python Tkinter 简单登录界面的实现就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com