资源简介
python 编写用户登录界面
1.输入用户名密码
2.认证成功后显示欢迎信息
3.输错三次后锁定
代码片段和文件信息
# -*- coding: utf-8 -*-
# -*- coding: cp936 -*-
import getpass
import Tkinter as tk
import time
import datetime
import tkMessageBox
“““
1.输入用户名密码
2.认证成功后显示欢迎信息
3.输错三次后锁定
“““
count = 0
def tick():
global time1
# 从运行程序的计算机上面获取当前的系统时间
time2 = time.strftime(‘%Y-%m-%d %H:%M:%S‘)
# 如果时间发生变化,代码自动更新显示的系统时间
if time2 != time1:
time1 = time2
clock.config(text=time2)
# calls itself every 200 milliseconds
# to update the time display as needed
# could use >200 ms but display gets jerky
clock.after(200 tick)
def handler():
‘‘‘事件处理函数‘‘‘
global count
global t1 t2
username = entry.get()
password = entry2.get()
if count > 3:
t2 = time.strftime(‘%Y-%m-%d %H:%M:%S‘ time.localtime())
t2= datetime.datetime.strptime(t2‘%Y-%m-%d %H:%M:%S‘)
dateline = datetime.timedelta( seconds=12 minutes=0 hours=0)
if (dateline - (t2 - t1)).days == 0:
print (u‘密码输入错误超过3次,该账号已被锁定,请‘)
print dateline - (t2 - t1)
print (u‘小时之后再试‘ )
var = ‘密码输入错误超过3次,该账号已被锁定,请‘ + str(dateline - (t2 - t1)) + ‘小时之后再试‘
tkMessageBox.showwarning(‘警告‘ var )
if (dateline - (t2 - t1)).days < 0:
count = 0
print (u‘账号锁定已解除,请输入正确的账号密码!‘)
tkMessageBox.showwarning(‘警告‘‘账号锁定已解除,请输入正确的账号密码!‘)
else:
if username == ‘‘ and password == ‘‘:
tkMessageBox.showinfo(‘警告‘‘账号和密码不能为空‘)
elif username == ‘‘ and password != ‘‘:
tkMessageBox.showinfo(‘警告‘‘账号不能为空‘)
elif username != ‘‘ and password == ‘‘:
tkMessageBox.showinfo(‘警告‘‘密码不能为空‘)
else:
if username == ‘Navy‘ and password == ‘9527‘:
print(u‘欢迎 Navy‘)
window.destroy()
tkMessageBox.showinfo(‘主页面‘‘欢迎 Navy‘)
else:
- 上一篇:Python imutils包
- 下一篇:python TCP聊天程序
相关资源
- Instant Pygame for Python Game Development How
- Biopython Tutorial
- Think Python 2nd
- 一个小小的表白程序(python)
- Python课堂笔记(高淇400集第一季)
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- python实现自动操作windows应用
- pyqt5动态加载ui文件,动态加载背景图
- 窗口动态镶嵌ui窗体
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
川公网安备 51152502000135号
评论
共有 条评论