Python-GUI程序设计-2

Posted 易行软件

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python-GUI程序设计-2相关的知识,希望对你有一定的参考价值。

代码演示:

import tkinter as tk
from tkinter import messagebox as msgbox

def LoginFun():
    sPass=enPass.get()
    if(sPass=="htzd"):
        labTip.config(text="登录成功。密码是:{}".format(sPass))
        msgbox.showinfo("温馨提示","登录成功.")

    else:
        labTip.config(text="登录失败。密码是:{}".format(sPass))
        msgbox.showerror("温馨提示","登录失败.")        

w=tk.Tk()
w.title("登录演示")
w.geometry("400x300")
labTip=tk.Label(w,text="Hello!")
labTip.pack()

enPass=tk.Entry(w)
enPass.pack()

btnLogin=tk.Button(w,text="登录",command=LoginFun)
btnLogin.pack()


w.mainloop()

 

以上是关于Python-GUI程序设计-2的主要内容,如果未能解决你的问题,请参考以下文章

Python-GUI程序设计-3

Python-GUI程序设计-3

Python-GUI程序设计

Python-GUI编程-PyQt5

python-GUI

微信小程序代码片段