超市仓库管理系统python+tkinter
一个非常简陋的作业…
结果图片
关于
管理员登录
Python代码
import pymssql
from tkinter import *
import tkinter as tk
import tkinter.font as tkFont
import tkinter.messagebox as messagebox
from PIL import Image, ImageTk
class AdminPage:
def __init__(self,window):
# top = tk.Toplevel()
#self.root1 = Tk()
# window.update()
window.destroy()
self.root1= tk.Toplevel()
self.root1.geometry('960x540')
self.root1.title('请登录')
image = Image.open("C:/acg.jpg")
photo = ImageTk.PhotoImage(image.resize((960,540)))
Lab= tk.Label(self.root1,text='',image = photo)
Lab.pack()#设置主界面
label = tk.Label(self.root1, text='账号',font=('华文行楷', 20),bg='Ivory', width=5, height=1)
label.place(x = 100, y=170)
self.w = tk.Entry(self.root1, width=20, font=tkFont.Font(size=14), bg='Ivory')
self.w.place(x = 175, y = 175)
label1 = tk.Label(self.root1, text='密码',font=('华文行楷', 20),bg='Ivory',width=5, height=1)
label1.place(x = 100, y=220)
self.w1 = tk.Entry(self.root1, width=20, font=tkFont.Font(size=14), bg='Ivory',show = "*")
self.w1.place(x = 175, y = 225)
btn1 = Button(self.root1, text="登陆", bg = 'lightcyan',width=8, font=('华文行楷', 30), command= self.login)
btn1.place(relx=0.2, rely=0.6, relwidth=0.2, relheight=0.1)
btn2 = Button(self.root1, text="返回首页", bg = 'lightcyan',width=8, font=('华文行楷', 30), command=lambda: start(self.root1))
btn2.place(relx=0.6, rely=0.6, relwidth=0.2, relheight=0.1)
self.root1.mainloop()
def login(self):
username = self.w.get()
password = self.w1.get()
if(username == 'h') and (password == '1'):
messagebox.showinfo('登录系统', '登录成功')
messagebox.showinfo('','正在链接数据库...')
conn = pymssql.connect(
host='localhost',
database='master',
charset = 'GBK')
cur = conn.cursor()
if cur:
messagebox.showinfo('',"连接成功!")
operatechoice(self.root1)
#messagebox.showinfo('登录系统', '登录成功')
else:
messagebox.showinfo('登录系统', '登录失败,用户名或密码错误')
class AdminPage1:
def __init__(self,window):
window.destroy()
self.root1= tk.Toplevel()
self.root1.geometry('960x540')
self.root1.title('请登录')
image = Image.open("C:/acg.jpg")
photo = ImageTk.PhotoImage(image.resize((960,540)))
Lab= tk.Label(self.root1,text='',image = photo)
Lab.pack()#设置主界面
label = tk.Label(self.root1, text='账号',font=('华文行楷', 20),bg='Ivory', width=5, height=1)
label.place(x = 100, y=170)
self.w = tk.Entry(self.root1, width=20, font=tkFont.Font(size=14), bg='Ivory')
self.w.place(x = 175, y = 175)
label1 = tk.Label(self.root1, text='密码',font=('华文行楷', 20),bg='Ivory',width=5, height=1)
label1.place(x = 100, y=220)
self.w1 = tk.Entry(self.root1, width=20, font=tkFont.Font(size=14), bg='Ivory',show = "*")
self.w1.place(x = 175, y = 225)
btn1 = Button(self.root1, text="登陆", bg = 'lightcyan',width=8, font=('华文行楷', 30), command= self.login)
btn1.place(relx=0.2, rely=0.6, relwidth=0.2, relheight=0.1)
btn2 = Button(self.root1, text="返回首页", bg = 'lightcyan',width=8, font=('华文行楷', 30), command=lambda: start(self.root1))
btn2.place(relx=0.6, rely=0.6, relwidth=0.2, relheight=0.1)
self.root1.mainloop()
def login(self):
username = self.w.get()
password = self.w1.get()
if(username == 'c') and (password == '1'):
messagebox.showinfo('登录系统', '登录成功')
messagebox.showinfo('','正在链接数据库...')
conn = pymssql.connect(
host='localhost',
database='master',
charset = 'GBK')
cur = conn.cursor()
if cur:
messagebox.showinfo('',"连接成功!")
operatechoice1(self.root1)
#messagebox.showinfo('登录系统', '登录成功')
else:
messagebox.showinfo('登录系统', '登录失败,用户名或密码错误')
class operatechoice1:
def __init__(self,window):
window.update()
window.destroy()
self.root= tk.Toplevel()
self.root.geometry('960x540')
self.root.title('操作选择')
image = Image.open("C:/acg1.jpg")
photo = ImageTk.PhotoImage(image.resize((960,540)))
Lab= tk.Label(self.root,text='',image = photo)
Lab.pack()#设置主界面
btn1 = Button(self.root, text="SQL操作", width=8, font=('华文行楷', 20),bg = 'lightcyan',command = lambda: operate(self.root))
btn1.place(relx=0.2, rely=0.6, relwidth=0.2, relheight=0.1)
btn2 = Button(self.root, text="返回", width=8, font=('华文行楷', 20), bg = 'lightcyan',command=lambda: AdminPage1(self.root))
btn2.place(relx=0.6, rely=0.6, relwidth=0.2, relheight=0.1)
btn3 = Button(self.root, text="查询操作", width=8, font=('华文行楷', 20), bg = 'lightcyan',command=lambda: select1(self.root))
btn3.place(relx=0.2, rely=0.2, relwidth=0.2, relheight=0.1)
btn4 = Button(self.root, text="删除操作", width=8, font=('华文行楷', 20), bg = 'lightcyan',command=lambda: delete1(self.root))
btn4.place(relx=0.6, rely=0.2, relwidth=0.2, relheight=0.1)
self.root.mainloop()
class operatechoice:
def __init__(self,window):
window.update()
window.destroy()
self.root= tk.Toplevel()
self.root.geometry('960x540')
self.root.title('操作选择')
image = Image.open("C:/acg1.jpg")
photo = ImageTk.PhotoImage(image.resize((960,540)))
Lab= tk.Label(self.root,text='',image = photo)
Lab.pack()#设置主界面
btn1 = Button(self.root, text="SQL操作", width=8, font=('华文行楷', 20),bg = 'lightcyan',command = lambda: operate(self.root))
btn1.place(relx=0.2, rely=0.6, relwidth=0.2, relheight=0.1)
btn2 = Button(self.root, text="返回", width=8, font=('华文行楷', 20), bg = 'lightcyan',command=lambda: AdminPage(self.root))
btn2.place(relx=0.6, rely=0.6, relwidth=0.2, relheight=0.1)
btn3 = Button(self.root, text="查询操作", width=8, font=('华文行楷', 20), bg = 'lightcyan',command=lambda: select(self.root))
btn3.place(relx=0.2, rely=0.2, relwidth=0.2, relheight=0.1)
btn4 = Button(self.root, text="插入操作", width=8, font=('华文行楷', 20), bg = 'lightcyan',command=lambda: insert(self.root))
btn4.place(relx=0.2, rely=0.4, relwidth=0.2, relheight=0.1)
btn4 = Button(self.root, text="删除操作", width=8, font=('华文行楷', 20), bg = 'lightcyan',command=lambda: delete(self.root))
btn4.place(relx=0.6, rely=0.2, relwidth=0.2, relheight=0.1)
btn4 = Button(self.root, text="更新操作", width=8, font=('华文行楷', 20), bg = 'lightcyan',command=lambda: update(self.root))
btn4.place(relx=0.6, rely=0.4, relwidth=0.2, relheight=0.1)
self.root.mainloop()
class update:
def __init__(self,window):
window.update()
window.destroy()
self.root= tk.Toplevel()
self.root.geometry('960x540')
self.root.title('更新操作')
image = Image.open("C:/acg1.jpg")
photo = ImageTk.PhotoImage(image.resize((960,540)))
Lab= tk.Label(self.root,text='',image = photo)
Lab.pack()#设置主界面
btn1 = Button(self.root, text="更新物品信息", width=8, font=('华文行楷', 20),bg = 'lightcyan',command = lambda: self.up(self.root))
btn1.place(relx=0.2, rely=0.2, relwidth=0.2, relheight=0.1)
btn2 = Button(self.root, text="返回", width=8, font=('华文行楷', 20), bg = 'lightcyan',command=lambda: operatechoice(self.root))
btn2.place(relx=0.6, rely=0.6, relwidth=0.2, relheight=0.1)
self.root.mainloop()
def up(self,window):
window.update()
window.destroy()
self.root= tk.Toplevel()
self.root.geometry('960x540')
self.root.title('选择更新')
image = Image.open("C:/acg1.jpg")
photo = ImageTk.PhotoImage(image.resize((960,540)))
Lab= tk.Label(self.root,text='',image = photo)
Lab.pack()#设置主界面
labe_l = tk.Label(self.root, text='请选择需更新的信息:',font=('华文行楷', 20), width=20, height=1)
labe_l.place(x = 0, y=0)
labe_2 = tk.Label(self.root, text='物品序号:',font=('华文行楷', 20),bg='Ivory', width=10, height=1)
labe_2.place(relx=0.05, rely=0.1)
labe1 = tk.Label(self.root, text='物品名称:',font=('华文行楷', 20),bg='Ivory', width=10, height=1)
labe1.place(relx=0.05, rely=0.2)
labe2 = tk.Label(self.root, text='物品数量:',font=('华文行楷', 20),bg='Ivory', width=10, height=1)
labe2.place(relx=0.05, rely=0.3)
labe3 = tk.Label(self.root, text='物品进价:',font=('华文行楷', 20),bg='Ivory', width=10, height=1)
labe3.place(relx=0.05, rely=0.4)
labe4 = tk.Label(self.root, text=