diff --git a/mainWindow.py b/mainWindow.py deleted file mode 100644 index a70c47e..0000000 --- a/mainWindow.py +++ /dev/null @@ -1,90 +0,0 @@ -import json -import os -import sqlite3 -import tkinter as tk -import tkinter.messagebox as msgbox -import subprocess - -window = 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)) - -# 管理员信息 -admin_info = "" -try: - with open("record.txt", "r") as file: - admin_info += file.readlines()[1] -except FileNotFoundError: - admin_info = "管理员信息未找到" -l_admin = tk.Label(window, text="Operator:", font=("幼圆", 10)) -l_admin.pack(side="left", anchor="nw") -l_adminName = tk.Label(window, text=admin_info) -l_adminName.pack(side="left", anchor="nw") - - -def admin_modify(): - subprocess.run(["python", "admin_modify.py"]) - - -btn_admin = tk.Button(window, text="修改信息", fg="black", borderwidth=2, command=admin_modify) -btn_admin.pack(side="right", anchor="ne") -# 功能面板 -l_functions = tk.Label(window, text="功能菜单", bg="lightpink", font=("黑体", 14)) -l_functions.place(x=20, y=50) - - -# 功能按钮 -# 添加车辆 -def add_info(): - subprocess.run(["python", "add_info.py"]) - - -# 查询信息 -def select_info(): - subprocess.run(["python", "select_info.py"]) - - -# 显示信息 -def findall(): - """将所有id写入sq_record.json""" - with open("sq_record.json", "w+") as fp: - con = sqlite3.connect("car_info.db") - cur = con.cursor() - cur.execute("select id from car") - indexList = cur.fetchall() - dumpList = [i[0] for i in indexList] - json.dump(dumpList, fp) - subprocess.run(["python", "results_found.py"]) - - -def resetAll(): - bool1 = msgbox.askokcancel(message="此操作即将清空数据库中的所有车辆数据,请确认") - if bool1: - try: - os.remove("car_info.db") - except FileNotFoundError: - msgbox.showerror(message="数据库文件未找到") - return - subprocess.run(["python", "initiation.py"]) - msgbox.showinfo(message="已重置") - - -# 按钮 -btn_add = tk.Button(window, text="添加/更新信息", width=14, font=("楷体", 12), command=add_info) -btn_select = tk.Button(window, text="查询信息", width=14, font=("楷体", 12), command=select_info) -btn_findall = tk.Button(window, text="查看所有/出场", width=14, font=("楷体", 12), command=findall) -btn_reset = tk.Button(window, text="重置数据库", width=14, font=("楷体", 12), command=resetAll) -btn_exit = tk.Button(window, text="退出登录", width=14, font=("黑体", 14), command=window.quit) -# 放置 间隔40 -btn_add.place(x=40, y=90) -btn_select.place(x=180, y=90) -btn_findall.place(x=40, y=130) -btn_reset.place(x=180, y=130) -btn_exit.place(x=100, y=200) - -window.mainloop()