from tkinter import *
from tkinter import messagebox
from db import Database
db = Database('database.db')
def populate_list():
parts_list.delete(0, END)
for row in db.fetch():
parts_list.insert(END, row)
def add_item():
if part_text.get() == '' or customer_text.get() == '' or retailer_text.get() == '' or price_text.get() == '':
messagebox.showerror('Required Fields', 'Please include all fields')
return
db.insert(part_text.get(), customer_text.get(),
retailer_text.get(), price_text.get())
parts_list.delete(0, END)
parts_list.insert(END, (part_text.get(), customer_text.get(),
retailer_text.get(), price_text.get()))
clear_text()
populate_list()
def select_item(event):
try:
global selected_item
index = parts_list.curselection()[0]
selected_item = parts_list.get(index)
part_entry.delete(0, END)
part_entry.insert(END, selected_item[1])
customer_entry.delete(0, END)
customer_entry.insert(END, selected_item[2])
retailer_entry.delete(0, END)
retailer_entry.insert(END, selected_item[3])
price_entry.delete(0, END)
price_entry.insert(END, selected_item[4])
except IndexError:
pass
def remove_item():
db.remove(selected_item[0])
clear_text()
populate_list()
def update_item():
db.update(selected_item[0], part_text.get(), customer_text.get(),
retailer_text.get(), price_text.get())
populate_list()
def clear_text():
part_entry.delete(0, END)
customer_entry.delete(0, END)
retailer_entry.delete(0, END)
price_entry.delete(0, END)
app = Tk()
part_text = StringVar()
part_label = Label(app, text='Accessory Name', font=('bold', 14), pady=20)
part_label.grid(row=0, column=0, sticky=W)
part_entry = Entry(app, textvariable=part_text)
part_entry.grid(row=0, column=1)
customer_text = StringVar()
customer_label = Label(app, text='Customer', font=('bold', 14))
customer_label.grid(row=0, column=2, sticky=W)
customer_entry = Entry(app, textvariable=customer_text)
customer_entry.grid(row=0, column=3)
retailer_text = StringVar()
retailer_label = Label(app, text='Retailer', font=('bold', 14))
retailer_label.grid(row=1, column=0, sticky=W)
retailer_entry = Entry(app, textvariable=retailer_text)
retailer_entry.grid(row=1, column=1)
price_text = StringVar()
price_label = Label(app, text='Price', font=('bold', 14))
price_label.grid(row=1, column=2, sticky=W)
price_entry = Entry(app, textvariable=price_text)
price_entry.grid(row=1, column=3)
parts_list = Listbox(app, height=8, width=50, border=0)
parts_list.grid(row=3, column=0, columnspan=3, rowspan=6, pady=20, padx=20)
scrollbar = Scrollbar(app)
scrollbar.grid(row=3, column=3)
parts_list.configure(yscrollcommand=scrollbar.set)
scrollbar.configure(command=parts_list.yview)
parts_list.bind('<<ListboxSelect>>', select_item)
add_btn = Button(app, text='Add', width=12, command=add_item)
add_btn.grid(row=2, column=0, pady=20)
remove_btn = Button(app, text='Delete', width=12, command=remove_item)
remove_btn.grid(row=2, column=1)
update_btn = Button(app, text='Update', width=12, command=update_item)
update_btn.grid(row=2, column=2)
clear_btn = Button(app, text='Clear Input', width=12, command=clear_text)
clear_btn.grid(row=2, column=3)
app.title('Accessory Management System')
app.geometry('550x350')
populate_list()
app.mainloop()
没有合适的资源?快使用搜索试试~ 我知道了~
Simple Accessory Inventory System in Python Free Source Code.zip
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共4个文件
py:2个
pyc:1个
db:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
0 下载量 17 浏览量
2023-11-03
16:44:34
上传
评论
收藏 4KB ZIP 举报
温馨提示
Simple Accessory Inventory System in Python Free Source Code.zip
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 4 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/4e5e76130c994bd080973e65cf6c3997_xiaoshun007.jpg!1)
xiaoshun007~
- 粉丝: 3872
- 资源: 3128
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)