资源简介
Tkinter+SQLite实现账号密码存储。由于生活中用到的账号密码太多了,因此开发这个工具,实现账号密码存储在数据库中,忘记了就可以查询。
代码片段和文件信息
# -*- coding:utf-8 -*-
from tkinter import *
from tkinter import messagebox
from PIL import ImageImageTk
import sqlite3
title = “提示“
def main():
global widthheightbt_query
root = Tk()
root.resizable(FalseFalse)
widthheight = root.maxsize()
site = ‘%dx%d+%d+%d‘%(480360(width-480)/2(height-320)/2)
root.geometry(site) #+%d+%d表示初始化时窗口所在的位置这里是窗口居中显示
root.title(“Account Database“)
#背景图片
bgImg = Image.open(‘./bg1_demo.jpg‘)
bgImg = ImageTk.PhotoImage(bgImg)
Label(rootimage=bgImg).grid()
#文本控件
Label(roottext=u‘账号:‘font=(‘楷体‘15)).place(relx=0.12rely=0.25)
en_account_var = StringVar()
Entry(roottextvariable=en_account_varwidth=‘25‘fg=‘gray‘relief=GROOVEbd=3).place(relx=0.32rely=0.25)
Label(roottext=u‘密码:‘font=(‘楷体‘15)).place(relx=0.12rely=0.40)
en_password_var = StringVar()
Entry(roottextvariable=en_password_varwidth=‘25‘fg=‘gray‘relief=GROOVEbd=3).place(relx=0.32rely=0.40)
Label(roottext=u‘备注:‘font=(‘楷体‘15)).place(relx=0.12rely=0.55)
en_info_var = StringVar()
Entry(roottextvariable=en_info_varwidth=‘25‘fg=‘gray‘relief=GROOVEbd=3).place(relx=0.32rely=0.55)
#Button组件
Button(roottext=‘新增‘bd=2width=5height=1command=lambda:insert(en_info_varen_account_varen_password_var)font=(‘楷体‘13)).place(relx=0.75rely=0.20)
Button(roottext=‘修改‘bd=2width=5height=1command=lambda:update(en_account_varen_password_varen_info_var)font=(‘楷体‘13)).place(relx=0.75rely=0.32)
bt_query = Button(roottext=‘查询‘bd=2width=5height=1command=lambda:query(en_info_var)font=(‘楷体‘13))
bt_query.place(relx=0.75rely=0.44)
Button(roottext=‘删除‘bd=2width=5height=1command=lambda:delete(en_account_varen_info_var)font=(‘楷体‘13)).place(relx=0.75rely=0.56)
#Menu菜单
menubar = Menu(root)
filemenu = Menu(menubartearoff=False)
menubar.add_cascade(label=‘更多‘menu=filemenu)
filemenu.add_command(label=‘创建数据表‘font=(‘楷体‘10)command=lambda :create())
filemenu.add_command(label=‘删除数据表‘font=(‘楷体‘10)command=lambda:drop())
root.config(menu=menubar)
root.mainloop()
def create():
try:
cursor.execute(‘‘‘CREATE TABLE ACCOUNTINFO (
ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
INFO CHAR(10) NOT NULL
ACCOUNT TEXT NOT NULL
PASSWORD TEXT NOT NULL
);‘‘‘) # 主键ID自增长
messagebox.showinfo(title“创建数据表ACCOUNTINFO成功“)
except Exception as e:
messagebox.showinfo(titlee.args[0])
return False
conn.commit()
def insert(en_info_varen_account_varen_password_var):
try:
sql = “INSERT INTO ACCOUNTINFO(INFOACCOUNTPASSWORD) VALUES (???)“ #官方建议insert最好用?作为占位符
cursor.execute(sql
- 上一篇:python爬取百度百科的页面
- 下一篇:PCA故障诊断python实现
相关资源
- 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应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
评论
共有 条评论