• tkinter做一个简单的登陆页面(十六)


    做一个简单的登陆页面

     1 import tkinter
     2 
     3 wuya = tkinter.Tk()
     4 wuya.title("wuya")
     5 wuya.geometry("900x380+300+150")
     6 
     7 
     8 # add image
     9 pic = r'/Users/ydj/Desktop/未命名文件夹/bg.gif'
    10 canvas = tkinter.Canvas(wuya)
    11 image_file = tkinter.PhotoImage(file=pic)
    12 image = canvas.create_image(0,0,anchor='nw',image=image_file)
    13 canvas.place(x=0,y=0,height=360, width=619)
    14 
    15 # add lable_title
    16 lp_title = tkinter.Label(wuya,text='舞涯管理系统',font=("Arial Black",22),fg='#32cd99')
    17 lp_title.place(x=625,y=150)
    18 
    19 # add copyright_lable
    20 copyright_lable = tkinter.Label(wuya,text='wuya @ copyright')
    21 copyright_lable.pack(side='bottom')
    22 
    23 # add name
    24 name_text = tkinter.Variable()
    25 name_lb = tkinter.Label(wuya,text='用户名:',font=('微软雅黑',13))
    26 name_lb.place(x=625,y=200)
    27 name_input = tkinter.Entry(wuya,textvariable=name_text,width=20)
    28 name_input.place(x=685,y=200)
    29 
    30 # add password
    31 pwd_text = tkinter.Variable()
    32 pwd_lb = tkinter.Label(wuya,text='密码:',font=('微软雅黑',13))
    33 pwd_lb.place(x=625,y=235)
    34 pwd_input = tkinter.Entry(wuya,width=20,textvariable=pwd_text)
    35 pwd_input.place(x=685,y=235)
    36 
    37 
    38 # username  and password is real
    39 def login_func():
    40     if name_text.get() == "":
    41         msg = "用户名不能为空"
    42     elif pwd_text.get() == "":
    43         msg = "密码不能为空"
    44     elif pwd_text.get()!="" and name_text.get()!="":
    45         msg = "登陆成功"
    46     else:
    47         msg = ""
    48     pwd_lb = tkinter.Label(wuya,text=msg,font=('微软雅黑',11),fg='red')
    49     pwd_lb.place(x=685, y=265)
    50 
    51 
    52 # add login_button
    53 login_button = tkinter.Button(wuya,text='登陆',font=('微软雅黑',12),command=login_func)
    54 login_button.place(x=770,y=280)
    55 
    56 # add quit_button
    57 quit_button = tkinter.Button(wuya,text='退出',font=('微软雅黑',12),command=wuya.quit)
    58 quit_button.place(x=700,y=280)
    59 
    60 wuya.mainloop()

    结果:

  • 相关阅读:
    关于生成并发唯一性流水号的解决方案
    父页面得到<iframe>
    struts2 convention配置中常见配置选项及说明
    Struts2下关于Calendar,date的一些处理
    怎样将用户名和密码保存到Cookie中?【转】
    如何调用用户控件(UserControl)的方法 .
    Struts遍历标签<s:iterator>总结 .
    在事业的开展上保持归零的心态
    这种日子最轻松,这样的人生最快乐
    诚实是人世间最珍贵的宝物,是每个人都应当坚守的伟大情操
  • 原文地址:https://www.cnblogs.com/tynam/p/8822616.html
Copyright © 2020-2023  润新知