基于python的停车场管理系统(毕设)
项目介绍
基于python+tkinter的停车场管理系统,thinter实现gui界面管理操作。主要包括车辆信息录入,删除,查询,修改等功能。
1.登录界面
import tkinter as tk
import tkinter.messagebox as msgbox
import os
import pickle
import threadingwindow = tk.Tk()
window.resizable(0, 0)
window.title("停车场信息管理系统")
# 窗口居中
ww, wh = 400, 250
sw, sh = window.winfo_screenwidth(), window.winfo_screenheight()
x, y = (sw - ww) / 2, (sh - wh) / 2
window.geometry("%dx%d+%d+%d" % (ww, wh, x, y))
# 欢迎使用
l_wlc = tk.Label(window, text="Welcome!", font=("Arial", 32))
l_wlc.pack()
# 用户名标签框
l_usr = tk.Label(window, text="用户名:")
l_usr.place(x=65, y=100)
l_key = tk.Label(window, text="密码:")
l_key.place(x=65, y=140)
# 用户名输入框
var1 = tk.StringVar()
var2 = tk.StringVar()
e_usr = tk.Entry(window, textvariable=var1)
e_key = tk.Entry(window, textvariable=var2, show="*")
e_usr.place(x=145, y=100)
e_key.place(x=145, y=140)
# 多线程实现同时打开新窗口和关闭本窗口
def tuichu():window.quit()
def open_new():os.system("mainWindow.py")# 登录
def login():t1 = threading.Thread(target=tuichu)t1.daemon = 1t2 = threading.Thread(target=open_new)t2.daemon = 1# 获得用户名字符串和密码字符串usr = var1.get()pwd = var2.get()# 登录前检查:判断输入框是否为空if usr != "":if pwd != "":# 将pickle内信息写入到listAll中listAll = []try:with open("administrators.pickle", "rb+") as fp:try:while True:temp = pickle.load(fp)listAll.append(temp)except EOFError:passexcept FileNotFoundError:with open("administrators.pickle", "wb") as fp:pickle.dump(("admin", "admin"), fp)else:pass# 检查该管理用户是否在存档中,密码是否匹配for person in listAll:if person[0] == usr and person[1] == pwd:with open("record.txt", "w+") as file:file.write("这是一个用于存储登录用户的名字的临时文件(注意:此文本由程序自动创建,不可擅自修改)\n"+usr)t1.start()t2.start()breakelse:msgbox.showerror(message="用户名或者密码错误!")else:msgbox.showerror("⚠", "请输入密码")else:msgbox.showerror("⚠", "请输入用户名")btn_login = tk.Button(window, text="登录", width=8, command=login)
btn_login.place(x=145, y=190)
# 退出
btn_exit = tk.Button(window, text="退出", width=8, command=window.quit)
btn_exit.place(x=220, y=190)
# 注册 调用注册界面
效果图:
2.注册界面
import tkinter as tk
import pickle
import tkinter.messagebox as msgboxwindow = tk.Tk()
window.resizable(0, 0)
window.title("注册")# 窗口居中
ww, wh = 400, 250
sw, sh = window.winfo_screenwidth(), window.winfo_screenheight()
x, y = (sw - ww) / 2, (sh - wh) / 2
window.geometry("%dx%d+%d+%d" % (ww, wh, x, y))# 用户名
l_usr = tk.Label(window, text="用户名:")
l_usr.place(x=50, y=60)
# 密码
l_key = tk.Label(window, text="密码:")
l_key.place(x=50, y=90)
# 密码确认
l_cf = tk.Label(window, text="确认密码:")
l_cf.place(x=50, y=120)# 单行文本框
var_usr = tk.StringVar()
var_key = tk.StringVar()
var_cf = tk.StringVar()
e_usr = tk.Entry(window, width=35, textvariable=var_usr)
e_key = tk.Entry(window, width=35, textvariable=var_key)
e_cf = tk.Entry(window, width=35, textvariable=var_cf)
e_usr.place(x=120, y=60)
e_key.place(x=120, y=90)
e_cf.place(x=120, y=120)def check_or_create(yonghu, mima):listAll = []with open("administrators.pickle", "rb") as fp:try:while True:temp = pickle.load(fp)listAll.append(temp)except EOFError:pass# 读取了空文件的操作if len(listAll) != 0:for person in listAll:if person[0] == yonghu:msgbox.showerror(message="用户已存在")breakelse:# 写入当前用户信息with open("administrators.pickle", "ab") as fp:pickle.dump((yonghu, mima), fp)msgbox.showinfo(message="恭喜,创建成功!")# 按钮设置
def save():# 获取输入信息usr = var_usr.get()key = var_key.get()cf = var_cf.get()# 先检查用户名输入是否为空,若为空则报错if usr != "":if key != "":if cf != "":# 先检查两次密码是否一致if key == cf:# 试图打开文件并读取内容,若文件不存在则新建并初始化try:check_or_create(usr, key)except FileNotFoundError:with open("administrators.pickle", "wb") as fp:pickle.dump(("admin", "admin"), fp)else:passelse:msgbox.showerror(title="⚠", message="两次密码不一致")else:msgbox.showerror("⚠", "确认密码为空!")else:msgbox.showerror("⚠", "密码为空!")else:msgbox.showerror("⚠", "用户名为空!")btn_save = tk.Button(window, text="保存", width=10, command=save)
btn_exit = tk.Button(window, text="取消", width=10, command=window.quit)
btn_save.place(x=140, y=170)
btn_exit.place(x=240, y=170)window.mainloop()
3.添加信息
import tkinter as tk
import tkinter.messagebox as msgbox
import sqlite3
from turtle import colordef addquote(string):"""为any加上引号"""return "\'" + str(string) + "\'"window = tk.Tk()
window.resizable(0, 0)
window.title("添加车辆信息")
# 窗口居中
ww, wh = 300, 300
sw, sh = window.winfo_screenwidth(), window.winfo_screenheight()
x, y = (sw - ww) / 2, (sh - wh) / 2
window.geometry("%dx%d+%d+%d" % (ww, wh, x, y))l_Id = tk.Label(window, text="车牌号:")
l_Name = tk.Label(window, text="姓名:")
l_Color = tk.Label(window, text="颜色:")
l_Addr = tk.Label(window, text="住址:")
l_Phone = tk.Label(window, text="电话:")# 间隔30
l_Id.place(x=10, y=20)
l_Name.place(x=10, y=50)
l_Color.place(x=10, y=80)
l_Addr.place(x=10, y=110)
l_Phone.place(x=10, y=140)# 录入框/获得单行文本框的信息
def checkdata():if e_Id.get() is None:return Falsetry:int(e_Id.get())return Trueexcept ValueError:msgbox.showwarning(message="非法输入")return False
# 检查字符串是否由数字组成
def check_value(string):try:int(string)return Trueexcept ValueError:return False
var_id = tk.StringVar()
var_name = tk.StringVar()
var_color = tk.StringVar()
var_addr = tk.StringVar()
var_phone = tk.StringVar()e_Id = tk.Entry(window, width=30, textvariable=var_id)
e_Name = tk.Entry(window, width=30, textvariable=var_name)
e_Color = tk.Entry(window, width=30, textvariable=var_color)
e_Addr = tk.Entry(window, width=30, textvariable=var_addr)
e_Phone = tk.Entry(window, width=30, textvariable=var_phone,validate="focusout", invalidcommand=checkdata)# 间隔30
e_Id.place(x=60, y=20)
e_Name.place(x=60, y=50)
e_Color.place(x=60, y=80)
e_Addr.place(x=60, y=110)
e_Phone.place(x=60, y=140)# 按钮def func_save():# 检查车牌号是否为空,为空则报错 通过entry属性实现# todoif e_Id.get() == "":msgbox.showwarning(message="车牌号为空")else:ids, name, color, addr, phone = var_id.get(), var_name.get(), var_color.get(), var_addr.get(), var_phone.get() # 获得输入的文本内容con = sqlite3.connect("./car_info.db") # 连接数据库cur = con.cursor() # 创建游标对象# 尝试写入,如果遇到重复则报错,确认是否需要修改try:cur.execute('insert into car values("%s","%s","%s","%s","%s")' % (ids, name, color, addr, phone))msgbox.showinfo(message="添加成功!")window.quit()except sqlite3.IntegrityError:msgbox.showerror("⚠", "车牌号重复")res = msgbox.askyesno("⚠", "是否需要覆盖")if res is True:res2 = msgbox.askokcancel("⚠", "一旦确认则无法撤销,请确认")if res2 is True:cur.execute("update car set name=?, color=?, addr=?, phone=? where id=?", (name, color, addr, phone, ids))# else:# window.quit()con.commit()cur.close()con.close()btn_save = tk.Button(window, text="保存", width=10, command=func_save)
btn_exit = tk.Button(window, text="退出", width=10, command=window.quit)
btn_save.place(x=110, y=220)
btn_exit.place(x=200, y=220)window.mainloop()
由于文件太多,全部项目请访问
https://download.csdn.net/download/qq_45056668/85695201
基于python的停车场管理系统(毕设)相关推荐
- 基于python的停车场管理系统的设计与实现/智能停车管理系统
摘要 车位信息是停车场供应用户必不可少的一个部分.在停车场发展的整个过程中,车位信息担负着最重要的角色.为满足如今日益复杂的管理需求,各类系统管理程序也在不断改进.本课题所设计的停车场管理系统,使用D ...
- 计算机毕业设计系列基于JavaWeb小区停车场管理系统
目录 一.项目介绍 二.开题报告 三.项目截图 四.源码获取 一.项目介绍 计算机毕业设计系列基于JavaWeb小区停车场管理系统 本项目是一款基于JSP的智能化停车场管理系统,主要针对计算机相关专业 ...
- 基于JAVA智能停车场管理系统计算机毕业设计源码+系统+数据库+lw文档+部署
基于JAVA智能停车场管理系统计算机毕业设计源码+系统+数据库+lw文档+部署 基于JAVA智能停车场管理系统计算机毕业设计源码+系统+数据库+lw文档+部署 本源码技术栈: 项目架构:B/S架构 开 ...
- 基于JAVAEE的停车场管理系统(论文+PPT+源码
详情介绍 毕业设计(论文) 论文题目 基于JAVAEE的停车场管理系统 Thesis Topic JAVAEE – based parking management system 毕业设计(论文)任务 ...
- python管理系统-基于Python实现用户管理系统
基于Python的用户管理小系统,包含文件读写操作,实现了用户信息注册和登录的简单功能. class userLogReg: """ Created on 2018.11 ...
- python 工资管理软件_基于[Python]的员工管理系统
基于[Python]的员工管理系统 -------------------------------- 简介 使用python语言来完成一个员工管理系统,员工信息包含:员工工号,姓名, 年龄,性别,职位 ...
- 基于java Web停车场管理系统源码和论文
开发工具:idea (eclipse) 环境:jdk1.8 mysql5.7 tomcat 随着时代的发展与科技的进步,停车场信息管理的方式也随之改变.譬如,以前的纸质记录数据并管理数据,到现在 ...
- 基于Python的超市管理系统毕业设计源码111042
目 录 摘要 1 绪论 1.1研究背景 1.2研究现状 1.3系统开发技术的特色 1.4论文结构与章节安排 2基于Python的 超市管理系统 系统分析 2.1 可行性分析 2.2 系统流程分析 2 ...
- 基于java小区停车场管理系统计算机毕业设计源码+系统+lw文档+mysql数据库+调试部署
基于java小区停车场管理系统计算机毕业设计源码+系统+lw文档+mysql数据库+调试部署 基于java小区停车场管理系统计算机毕业设计源码+系统+lw文档+mysql数据库+调试部署 本源码技术栈 ...
最新文章
- c语言连接数据库例子,c语言操作mysql数据库小例子_互帮互助(C language MySQL database operation example _ mutual help).doc...
- crontab 总结
- 今天遇到一个很奇怪的问题,XP系统屏幕全部旋转90度
- var_export-输出或返回一个变量的字符串表示
- vs 输入代码时出现火花_在Visual Basic的立即窗口内输入以下语句 X=65
- python 案例串接_Python基础系例--字典串操作
- VC 获取当前工作目录和执行目录的一些方法
- FreeRTOS源码分析与应用开发02:任务管理
- slf4j mysql_能显示sql语句,没有报错,但是MySQL里没有表?还有,slf4j是必须的吗?...
- XML To Linq 读取Sharepoint列表中的附件列信息
- [篇三章一]_微软虚拟机 Hyper-V 上安装纯 MS-DOS 6.22 系统
- AXI Memory-Mapped SRIO收发控制器
- android flash插件安装失败,安卓手机怎么安装Adobe Flash Player插件
- 用 Amazon Web Services 进行云计算,第 3 部分:用 EC2 根据需要提供服务器
- wps下载的简历无法删除空白页
- Java后端春秋招之旅
- GBase8s数据库REFERENCES 子句
- android常用控件实验报告,ui设计实验报告.doc
- 网约车大战重来:易到回归降佣金,美团入局每单补贴超20元
- native crash