Compare commits

...

35 Commits
0.0.1 ... main

Author SHA1 Message Date
pvcfg6a7k 0467fcae4c ADD file via upload
9 months ago
pvcfg6a7k 497bcc2629 Update README.md
9 months ago
p2apfqmgs 415d16e0ff Add PPT信息2
9 months ago
p2apfqmgs 4c149e1b52 Add 给PPT留一些信息
9 months ago
p2apfqmgs 434ef694a8 Update README.md
9 months ago
p2apfqmgs 6f011665a9 Update ui.py
9 months ago
p2apfqmgs 49839bce03 Update calculate.py
9 months ago
p2apfqmgs 4f4dda4e64 Update ui.py
9 months ago
pvcfg6a7k 1cff9723fe Update README.md
10 months ago
p2apfqmgs 9d0a64b1b0 Update ui.py
10 months ago
p2apfqmgs e822f852cb Update README.md
10 months ago
p2apfqmgs 46d889eb50 Update README.md
10 months ago
p2apfqmgs 40fbecf6b9 Update README.md
10 months ago
pvcfg6a7k 5ff5e52019 Update README.md
10 months ago
pvcfg6a7k d17b444a39 Update README.md
10 months ago
p2apfqmgs 3d1a193aa6 Update 说明.txt
11 months ago
p2apfqmgs f5daf109be Update README.md
11 months ago
p2apfqmgs 7c19ca5a9f ADD file via upload
11 months ago
p2apfqmgs f3bcbbcc46 ADD file via upload
11 months ago
p2apfqmgs a8617d84a6 Update books.csv
11 months ago
pvcfg6a7k 4b7901b0c5 Update README.md
11 months ago
p2apfqmgs f156cadf68 Update README.md
11 months ago
p2apfqmgs 4322a5132e ADD file via upload
11 months ago
p2apfqmgs 9822c1810f ADD file via upload
11 months ago
p2apfqmgs b84ce9fb75 ADD file via upload
11 months ago
p2apfqmgs 193a188ef7 ADD file via upload
11 months ago
p2apfqmgs 5594771c21 Update README.md
11 months ago
p2apfqmgs 484f4faae0 Update README.md
11 months ago
p2apfqmgs 0968e0c58a Update README.md
11 months ago
p2apfqmgs 974b6e2725 Update README.md
11 months ago
p2apfqmgs 83969d63cc Update README.md
11 months ago
pvcfg6a7k db463f727c Update README.md
11 months ago
pvcfg6a7k 1ff3574427 Update README.md
11 months ago
p2apfqmgs ec1b43a729 Update README.md
11 months ago
p2apfqmgs 0189eef41b Update README.md
11 months ago

@ -0,0 +1,69 @@
在您的GUI类中主要使用了以下方法我将逐个进行讲解
1. **__init__ 方法**
```python
def __init__(self):
# 初始化主窗口
self.root = tk.Tk()
# 设置窗口标题、大小和背景色
self.create_widgets() # 创建所有组件
self.setup_layout() # 设置布局
```
作用类的构造函数初始化GUI界面创建主窗口和基本组件。
2. **create_widgets 方法**
```python
def create_widgets(self):
# 创建主框架、标题标签
# 创建输入框和按钮
# 创建结果显示区域和滚动条
```
作用:创建所有界面组件,但不设置布局。
3. **setup_layout 方法**
```python
def setup_layout(self):
# 使用pack和grid布局管理器
# 排列所有组件的位置
```
作用:设置所有组件的布局和排列方式。
4. **fuzzy_search 方法**
```python
def fuzzy_search(self):
# 获取搜索关键词
# 禁用按钮防止重复点击
# 调用模糊搜索功能
# 处理并显示结果
# 恢复按钮状态
```
作用:处理模糊搜索按钮点击事件,执行模糊搜索并显示结果。
5. **start 方法**
```python
def start(self):
# 获取ISBN输入
# 禁用查询按钮
# 执行ISBN查询
# 处理并显示结果
# 恢复按钮状态
```
作用处理查询按钮点击事件执行ISBN查询并显示结果。
6. **display_results 方法**
```python
def display_results(self, results):
# 清空结果区域
# 根据结果类型(字典/列表/字符串)
# 格式化显示查询结果
# 设置文本区域为只读
```
作用:统一格式化显示查询结果,支持多种结果类型。
每个方法都遵循单一职责原则,共同协作完成图书查询系统的功能。关键点包括:
- 按钮状态管理(禁用/恢复)
- 异常处理机制
- 结果格式化显示
- 界面更新机制
这种设计使得代码结构清晰,易于维护和扩展。

@ -15,3 +15,83 @@ special
1.使用自定义对象:图书,用户
2.尝试连接数据库PostgreSQL 16.1通过Navicat管理来管理数据
'''
3.24
做出以下调整:
1不用navicat,就用csv文件能做出东西就行1个学分不值得拼命
2还是需要一个图形界面这个是加分项
3增删改查都要全面
4用户只可以查管理员可以增删改这些建立在登录模块的基础上
5还有一个核心功能就是记录用户的借书记录书目时间应还时间
'''
3.25 管理员2
1.关于图形界面tkinter库内容简单无需下载
2.关于管理权限将权限单独存为一个元组需要删改增需要最高权限管理员来做此模块应有1.校验用户名密码2.录入用户的基本信息如姓名、联系方式、借阅证号等记录用户的借阅历史包括借阅时间、归还时间、借阅图书等。3.管理权限并根据权限进入不同交互界面的主要功能
3.关于图书管理此模块应具有1.查找图书提供多种检索方式如按书名、作者、ISBN号、分类等查询图书信息。2.归还图书处理用户的借阅和归还请求更新图书的库存状态对逾期未还的图书进行提醒并计算罚款金额允许用户预约已借出的图书当图书归还时通知用户3.图书分类管理:对图书进行分类管理,如文学、科技、历史等,便于用户按类别查找图书。
以上为一个图书管理系统的主干,以下为附加内容:
1.安全性考虑
2.通过用户借阅图书推测出用户喜好并推荐图书
3.统计每种图书的借阅数量供下次买书参考
4.是否需要对用户等级进行分类比如借数超过50本还书时间限制延长一个周
3.26管理员1
1.具体的文件实施形式已用csv建立
2.归还时间实现方法:
只记录借书日期,读取当前日期,而后进行计算
3.搜索isbn只支持精确搜索书名应支持模糊搜索我们可以尝试把在那个成语的模糊查询功能做到书名搜索里
4.如果有条件,再做一个分类筛选功能
3.27管理员1
1.生成了一些books数据
2.实现了了基础UI与底层计算的接入
3.目前UI界面太丑太简陋
4.底层计算目前只实现了ISBN精确查询需要扩充的内容很多
4.10管理员1
考虑到下周没什么时间而这个作业18号就截止了
所以事情还是很紧急的
PPT汇报具体要求什么的4.11课上问问,同时也可以尝试能不能延期
现在急需将其完善,可以在功能上进一步简化,而图形界面能看即可,确保能交差
如果可以延期就再美化,不能就能交差即可
def start(self):
"""处理查询按钮点击事件"""
isbn = self.entry00.get().strip()
if not isbn:
self.result_text.config(state=tk.NORMAL)
self.result_text.delete(1.0, tk.END)
self.result_text.insert(tk.END, "请输入ISBN编号")
self.result_text.config(state=tk.DISABLED)
return
# 禁用按钮防止重复点击
self.query_button.config(state=tk.DISABLED, text="查询中...")
self.root.update() # 强制更新界面
try:
result = query_isbn(isbn)
self.result_text.config(state=tk.NORMAL)
self.result_text.delete(1.0, tk.END)
if isinstance(result, dict):
formatted_result = "\n".join(f"{k}: {v}" for k, v in result.items())
self.result_text.insert(tk.END, formatted_result)
elif isinstance(result, list):
# 修改为与模糊搜索相同的输出格式
formatted_results = "\n\n".join(
"\n".join(f"{k}: {v}" for k, v in book.items())
for book in result
)
self.result_text.insert(tk.END, formatted_results)
else:
self.result_text.insert(tk.END, result)
self.result_text.config(state=tk.DISABLED)
except Exception as e:
self.result_text.config(state=tk.NORMAL)
self.result_text.delete(1.0, tk.END)
self.result_text.insert(tk.END, f"查询出错: {str(e)}")
self.result_text.config(state=tk.DISABLED)
finally:
# 恢复按钮状态
self.query_button.config(state=tk.NORMAL, text="查询")

@ -0,0 +1,145 @@
isbn,title,author,category,status,place
9787111123456,Python编程实战,Eric Matthes,Programming,available,N2_045_3
9787111123457,百年孤独,Gabriel García Márquez,Literature,borrowed,S3_078_2
9787111123458,人类简史,Yuval Noah Harari,History,maintained,W1_112_4
9787111123459,人工智能革命,Thomas H. Cormen,AI,available,N3_023_5
9787111123460,唐简史,钱钟书,Literature,borrowed,S2_056_1
9787111123461,量子计算技术前沿,Andrew Ng,Science,available,N1_088_2
9787111123462,艺术鉴赏入门,E.H. Gombrich,Art,maintained,W4_099_3
9787111123463,被遗忘的春秋战国时代,Jared Diamond,History,available,S3_044_4
9787111123464,巴洛克艺术鉴赏,Cao Xueqin,Art,borrowed,N2_033_1
9787111123465,机器学习实战,Kevin Murphy,AI,available,W2_066_5
9787111123466,三体,刘慈欣,Science Fiction,maintained,S1_095_3
9787111123467,资本论,Karl Marx,Economics,available,N3_017_2
9787111123468,活着,余华,Literature,borrowed,W3_082_4
9787111123469,算法导论,Thomas H. Cormen,Computer Science,maintained,N2_033_1
9787111123470,时间简史,Stephen Hawking,Science,available,S2_070_3
9787111123471,围城,钱钟书,Literature,borrowed,W4_093_5
9787111123472,深度学习,Kevin Murphy,AI,available,N1_102_3
9787111123473,枪炮、病菌与钢铁,Jared Diamond,History,maintained,S1_055_2
9787111123474,1984,George Orwell,Literature,available,N2_068_1
9787111123475,小王子,Antoine de Saint-Exupéry,Children's Book,borrowed,W3_085_4
9787111123476,人类简史,Yuval Noah Harari,History,available,S2_088_5
9787111123477,Python基础教程,Eric Matthes,Programming,maintained,W4_096_3
9787111123478,艺术的故事,E.H. Gombrich,Art,available,S1_077_4
9787111123479,经济转型与政策分析,N. Gregory Mankiw,Economics,borrowed,N2_048_5
9787111123480,傲慢与偏见,Jane Austen,Literature,available,N1_045_3
9787111123481,量子力学导论,David Griffiths,Science,maintained,S3_066_2
9787111123482,红楼梦,Cao Xueqin,Literature,borrowed,W4_099_5
9787111123483,机器学习实战,Andrew Ng,AI,available,S2_033_1
9787111123484,活着,余华,Literature,maintained,N3_055_3
9787111123485,时间简史,Stephen Hawking,Science,available,S3_095_3
9787111123486,1984,George Orwell,Literature,borrowed,N2_068_1
9787111123487,三体,刘慈欣,Science Fiction,maintained,W3_100_5
9787111123488,枪炮、病菌与钢铁,Jared Diamond,History,available,S1_095_3
9787111123489,围城,钱钟书,Literature,borrowed,W4_093_5
9787111123490,Python编程从入门到实践,Eric Matthes,Programming,available,N3_077_2
9787111123491,艺术与错觉,E.H. Gombrich,Art,maintained,S2_088_2
9787111123492,小王子,Antoine de Saint-Exupéry,Children's Book,available,N3_077_3
9787111123493,经济转型与政策分析,N. Gregory Mankiw,Economics,borrowed,W4_095_5
9787111123494,人类简史,Yuval Noah Harari,History,available,S2_088_3
9787111123495,Python基础教程,Eric Matthes,Programming,maintained,W4_096_3
9787111123496,活着,余华,Literature,borrowed,N3_055_3
9787111123497,三体,刘慈欣,Science Fiction,available,W3_100_5
9787111123498,算法导论,Thomas H. Cormen,Computer Science,maintained,S2_077_4
9787111123499,时间简史,Stephen Hawking,Science,borrowed,S3_095_3
9787111123500,资本论,Karl Marx,Economics,available,N2_068_1
9787111123501,艺术的故事,E.H. Gombrich,Art,maintained,W4_099_3
9787111123502,枪炮、病菌与钢铁,Jared Diamond,History,available,S1_095_3
9787111123503,小王子,Antoine de Saint-Exupéry,Children's Book,borrowed,W3_085_4
9787111123504,Python编程实战,Eric Matthes,Programming,available,N2_045_3
9787111123505,百年孤独,Gabriel García Márquez,Literature,borrowed,S3_078_2
9787111123506,人类简史,Yuval Noah Harari,History,maintained,W1_112_4
9787111123507,人工智能革命,Thomas H. Cormen,AI,available,N3_023_5
9787111123508,唐简史,钱钟书,Literature,borrowed,S2_056_1
9787111123509,量子计算技术前沿,Andrew Ng,Science,available,N1_088_2
9787111123510,艺术鉴赏入门,E.H. Gombrich,Art,maintained,W4_099_3
9787111123511,被遗忘的春秋战国时代,Jared Diamond,History,available,S3_044_4
9787111123512,巴洛克艺术鉴赏,Cao Xueqin,Art,borrowed,N2_033_1
9787111123513,机器学习实战,Kevin Murphy,AI,available,W2_066_5
9787111123514,三体,刘慈欣,Science Fiction,maintained,S1_095_3
9787111123515,资本论,Karl Marx,Economics,available,N3_017_2
9787111123516,活着,余华,Literature,borrowed,W3_082_4
9787111123517,算法导论,Thomas H. Cormen,Computer Science,maintained,N2_033_1
9787111123518,时间简史,Stephen Hawking,Science,available,S2_070_3
9787111123519,围城,钱钟书,Literature,borrowed,W4_093_5
9787111123520,深度学习,Kevin Murphy,AI,available,N1_102_3
9787111123521,枪炮、病菌与钢铁,Jared Diamond,History,maintained,S1_055_2
9787111123522,1984,George Orwell,Literature,available,N2_068_1
9787111123523,小王子,Antoine de Saint-Exupéry,Children's Book,borrowed,W3_085_4
9787111123524,人类简史,Yuval Noah Harari,History,available,S2_088_5
9787111123525,Python基础教程,Eric Matthes,Programming,maintained,W4_096_3
9787111123526,艺术的故事,E.H. Gombrich,Art,available,S1_077_4
9787111123527,经济转型与政策分析,N. Gregory Mankiw,Economics,borrowed,N2_048_5
9787111123528,傲慢与偏见,Jane Austen,Literature,available,N1_045_3
9787111123529,量子力学导论,David Griffiths,Science,maintained,S3_066_2
9787111123530,红楼梦,Cao Xueqin,Literature,borrowed,W4_099_5
9787111123531,机器学习实战,Andrew Ng,AI,available,S2_033_1
9787111123532,活着,余华,Literature,maintained,N3_055_3
9787111123533,时间简史,Stephen Hawking,Science,available,S3_095_3
9787111123534,1984,George Orwell,Literature,borrowed,N2_068_1
9787111123535,三体,刘慈欣,Science Fiction,maintained,W3_100_5
9787111123536,枪炮、病菌与钢铁,Jared Diamond,History,available,S1_095_3
9787111123537,围城,钱钟书,Literature,borrowed,W4_093_5
9787111123538,Python编程从入门到实践,Eric Matthes,Programming,available,N3_077_2
9787111123539,艺术与错觉,E.H. Gombrich,Art,maintained,S2_088_2
9787111123540,小王子,Antoine de Saint-Exupéry,Children's Book,available,N3_077_3
9787111123541,经济转型与政策分析,N. Gregory Mankiw,Economics,borrowed,W4_095_5
9787111123542,人类简史,Yuval Noah Harari,History,available,S2_088_3
9787111123543,Python基础教程,Eric Matthes,Programming,maintained,W4_096_3
9787111123544,活着,余华,Literature,borrowed,N3_055_3
9787111123545,三体,刘慈欣,Science Fiction,available,W3_100_5
9787111123546,算法导论,Thomas H. Cormen,Computer Science,maintained,S2_077_4
9787111123547,时间简史,Stephen Hawking,Science,borrowed,S3_095_3
9787111123548,资本论,Karl Marx,Economics,available,N2_068_1
9787111123549,艺术的故事,E.H. Gombrich,Art,maintained,W4_099_3
9787111123550,枪炮、病菌与钢铁,Jared Diamond,History,available,S1_095_3
9787111123551,小王子,Antoine de Saint-Exupéry,Children's Book,borrowed,W3_085_4
9787111123552,Python编程实战,Eric Matthes,Programming,available,N2_045_3
9787111123553,百年孤独,Gabriel García Márquez,Literature,borrowed,S3_078_2
9787111123554,人类简史,Yuval Noah Harari,History,maintained,W1_112_4
9787111123555,人工智能革命,Thomas H. Cormen,AI,available,N3_023_5
9787111123556,唐简史,钱钟书,Literature,borrowed,S2_056_1
9787111123557,量子计算技术前沿,Andrew Ng,Science,available,N1_088_2
9787111123558,艺术鉴赏入门,E.H. Gombrich,Art,maintained,W4_099_3
9787111123559,被遗忘的春秋战国时代,Jared Diamond,History,available,S3_044_4
9787111123560,巴洛克艺术鉴赏,Cao Xueqin,Art,borrowed,N2_033_1
9787111123561,机器学习实战,Kevin Murphy,AI,available,W2_066_5
9787111123562,三体,刘慈欣,Science Fiction,maintained,S1_095_3
9787111123563,资本论,Karl Marx,Economics,available,N3_017_2
9787111123564,活着,余华,Literature,borrowed,W3_082_4
9787111123565,算法导论,Thomas H. Cormen,Computer Science,maintained,N2_033_1
9787111123566,时间简史,Stephen Hawking,Science,available,S2_070_3
9787111123567,围城,钱钟书,Literature,borrowed,W4_093_5
9787111123568,深度学习,Kevin Murphy,AI,available,N1_102_3
9787111123569,枪炮、病菌与钢铁,Jared Diamond,History,maintained,S1_055_2
9787111123570,1984,George Orwell,Literature,available,N2_068_1
9787111123571,小王子,Antoine de Saint-Exupéry,Children's Book,borrowed,W3_085_4
9787111123572,人类简史,Yuval Noah Harari,History,available,S2_088_5
9787111123573,Python基础教程,Eric Matthes,Programming,maintained,W4_096_3
9787111123574,艺术的故事,E.H. Gombrich,Art,available,S1_077_4
9787111123575,经济转型与政策分析,N. Gregory Mankiw,Economics,borrowed,N2_048_5
9787111123576,傲慢与偏见,Jane Austen,Literature,available,N1_045_3
9787111123577,量子力学导论,David Griffiths,Science,maintained,S3_066_2
9787111123578,红楼梦,Cao Xueqin,Literature,borrowed,W4_099_5
9787111123579,机器学习实战,Andrew Ng,AI,available,S2_033_1
9787111123580,活着,余华,Literature,maintained,N3_055_3
9787111123581,时间简史,Stephen Hawking,Science,available,S3_095_3
9787111123582,1984,George Orwell,Literature,borrowed,N2_068_1
9787111123583,三体,刘慈欣,Science Fiction,maintained,W3_100_5
9787111123584,枪炮、病菌与钢铁,Jared Diamond,History,available,S1_095_3
9787111123585,围城,钱钟书,Literature,borrowed,W4_093_5
9787111123586,Python编程从入门到实践,Eric Matthes,Programming,available,N3_077_2
9787111123587,艺术与错觉,E.H. Gombrich,Art,maintained,S2_088_2
9787111123588,小王子,Antoine de Saint-Exupéry,Children's Book,available,N3_077_3
9787111123589,经济转型与政策分析,N. Gregory Mankiw,Economics,borrowed,W4_095_5
9787111123590,人类简史,Yuval Noah Harari,History,available,S2_088_3
9787111123591,Python基础教程,Eric Matthes,Programming,maintained,W4_096_3
9787111123592,活着,余华,Literature,borrowed,N3_055_3
9787111123593,三体,刘慈欣,Science Fiction,available,W3_100_5
9787111123594,算法导论,Thomas H. Cormen,Computer Science,maintained,S2_077_4
9787111123595,时间简史,Stephen Hawking,Science,borrowed,S3_095_3
9787111123596,资本论,Karl Marx,Economics,available,N2_068_1
9787111123597,艺术的故事,E.H. Gombrich,Art,maintained,W4_099_3
9787111123598,枪炮、病菌与钢铁,Jared Diamond,History,available,S1_095_3
9787111123599,小王子,Antoine de Saint-Exupéry,Children's Book,borrowed,W3_085_4
1 isbn title author category status place
2 9787111123456 Python编程实战 Eric Matthes Programming available N2_045_3
3 9787111123457 百年孤独 Gabriel García Márquez Literature borrowed S3_078_2
4 9787111123458 人类简史 Yuval Noah Harari History maintained W1_112_4
5 9787111123459 人工智能革命 Thomas H. Cormen AI available N3_023_5
6 9787111123460 唐简史 钱钟书 Literature borrowed S2_056_1
7 9787111123461 量子计算技术前沿 Andrew Ng Science available N1_088_2
8 9787111123462 艺术鉴赏入门 E.H. Gombrich Art maintained W4_099_3
9 9787111123463 被遗忘的春秋战国时代 Jared Diamond History available S3_044_4
10 9787111123464 巴洛克艺术鉴赏 Cao Xueqin Art borrowed N2_033_1
11 9787111123465 机器学习实战 Kevin Murphy AI available W2_066_5
12 9787111123466 三体 刘慈欣 Science Fiction maintained S1_095_3
13 9787111123467 资本论 Karl Marx Economics available N3_017_2
14 9787111123468 活着 余华 Literature borrowed W3_082_4
15 9787111123469 算法导论 Thomas H. Cormen Computer Science maintained N2_033_1
16 9787111123470 时间简史 Stephen Hawking Science available S2_070_3
17 9787111123471 围城 钱钟书 Literature borrowed W4_093_5
18 9787111123472 深度学习 Kevin Murphy AI available N1_102_3
19 9787111123473 枪炮、病菌与钢铁 Jared Diamond History maintained S1_055_2
20 9787111123474 1984 George Orwell Literature available N2_068_1
21 9787111123475 小王子 Antoine de Saint-Exupéry Children's Book borrowed W3_085_4
22 9787111123476 人类简史 Yuval Noah Harari History available S2_088_5
23 9787111123477 Python基础教程 Eric Matthes Programming maintained W4_096_3
24 9787111123478 艺术的故事 E.H. Gombrich Art available S1_077_4
25 9787111123479 经济转型与政策分析 N. Gregory Mankiw Economics borrowed N2_048_5
26 9787111123480 傲慢与偏见 Jane Austen Literature available N1_045_3
27 9787111123481 量子力学导论 David Griffiths Science maintained S3_066_2
28 9787111123482 红楼梦 Cao Xueqin Literature borrowed W4_099_5
29 9787111123483 机器学习实战 Andrew Ng AI available S2_033_1
30 9787111123484 活着 余华 Literature maintained N3_055_3
31 9787111123485 时间简史 Stephen Hawking Science available S3_095_3
32 9787111123486 1984 George Orwell Literature borrowed N2_068_1
33 9787111123487 三体 刘慈欣 Science Fiction maintained W3_100_5
34 9787111123488 枪炮、病菌与钢铁 Jared Diamond History available S1_095_3
35 9787111123489 围城 钱钟书 Literature borrowed W4_093_5
36 9787111123490 Python编程从入门到实践 Eric Matthes Programming available N3_077_2
37 9787111123491 艺术与错觉 E.H. Gombrich Art maintained S2_088_2
38 9787111123492 小王子 Antoine de Saint-Exupéry Children's Book available N3_077_3
39 9787111123493 经济转型与政策分析 N. Gregory Mankiw Economics borrowed W4_095_5
40 9787111123494 人类简史 Yuval Noah Harari History available S2_088_3
41 9787111123495 Python基础教程 Eric Matthes Programming maintained W4_096_3
42 9787111123496 活着 余华 Literature borrowed N3_055_3
43 9787111123497 三体 刘慈欣 Science Fiction available W3_100_5
44 9787111123498 算法导论 Thomas H. Cormen Computer Science maintained S2_077_4
45 9787111123499 时间简史 Stephen Hawking Science borrowed S3_095_3
46 9787111123500 资本论 Karl Marx Economics available N2_068_1
47 9787111123501 艺术的故事 E.H. Gombrich Art maintained W4_099_3
48 9787111123502 枪炮、病菌与钢铁 Jared Diamond History available S1_095_3
49 9787111123503 小王子 Antoine de Saint-Exupéry Children's Book borrowed W3_085_4
50 9787111123504 Python编程实战 Eric Matthes Programming available N2_045_3
51 9787111123505 百年孤独 Gabriel García Márquez Literature borrowed S3_078_2
52 9787111123506 人类简史 Yuval Noah Harari History maintained W1_112_4
53 9787111123507 人工智能革命 Thomas H. Cormen AI available N3_023_5
54 9787111123508 唐简史 钱钟书 Literature borrowed S2_056_1
55 9787111123509 量子计算技术前沿 Andrew Ng Science available N1_088_2
56 9787111123510 艺术鉴赏入门 E.H. Gombrich Art maintained W4_099_3
57 9787111123511 被遗忘的春秋战国时代 Jared Diamond History available S3_044_4
58 9787111123512 巴洛克艺术鉴赏 Cao Xueqin Art borrowed N2_033_1
59 9787111123513 机器学习实战 Kevin Murphy AI available W2_066_5
60 9787111123514 三体 刘慈欣 Science Fiction maintained S1_095_3
61 9787111123515 资本论 Karl Marx Economics available N3_017_2
62 9787111123516 活着 余华 Literature borrowed W3_082_4
63 9787111123517 算法导论 Thomas H. Cormen Computer Science maintained N2_033_1
64 9787111123518 时间简史 Stephen Hawking Science available S2_070_3
65 9787111123519 围城 钱钟书 Literature borrowed W4_093_5
66 9787111123520 深度学习 Kevin Murphy AI available N1_102_3
67 9787111123521 枪炮、病菌与钢铁 Jared Diamond History maintained S1_055_2
68 9787111123522 1984 George Orwell Literature available N2_068_1
69 9787111123523 小王子 Antoine de Saint-Exupéry Children's Book borrowed W3_085_4
70 9787111123524 人类简史 Yuval Noah Harari History available S2_088_5
71 9787111123525 Python基础教程 Eric Matthes Programming maintained W4_096_3
72 9787111123526 艺术的故事 E.H. Gombrich Art available S1_077_4
73 9787111123527 经济转型与政策分析 N. Gregory Mankiw Economics borrowed N2_048_5
74 9787111123528 傲慢与偏见 Jane Austen Literature available N1_045_3
75 9787111123529 量子力学导论 David Griffiths Science maintained S3_066_2
76 9787111123530 红楼梦 Cao Xueqin Literature borrowed W4_099_5
77 9787111123531 机器学习实战 Andrew Ng AI available S2_033_1
78 9787111123532 活着 余华 Literature maintained N3_055_3
79 9787111123533 时间简史 Stephen Hawking Science available S3_095_3
80 9787111123534 1984 George Orwell Literature borrowed N2_068_1
81 9787111123535 三体 刘慈欣 Science Fiction maintained W3_100_5
82 9787111123536 枪炮、病菌与钢铁 Jared Diamond History available S1_095_3
83 9787111123537 围城 钱钟书 Literature borrowed W4_093_5
84 9787111123538 Python编程从入门到实践 Eric Matthes Programming available N3_077_2
85 9787111123539 艺术与错觉 E.H. Gombrich Art maintained S2_088_2
86 9787111123540 小王子 Antoine de Saint-Exupéry Children's Book available N3_077_3
87 9787111123541 经济转型与政策分析 N. Gregory Mankiw Economics borrowed W4_095_5
88 9787111123542 人类简史 Yuval Noah Harari History available S2_088_3
89 9787111123543 Python基础教程 Eric Matthes Programming maintained W4_096_3
90 9787111123544 活着 余华 Literature borrowed N3_055_3
91 9787111123545 三体 刘慈欣 Science Fiction available W3_100_5
92 9787111123546 算法导论 Thomas H. Cormen Computer Science maintained S2_077_4
93 9787111123547 时间简史 Stephen Hawking Science borrowed S3_095_3
94 9787111123548 资本论 Karl Marx Economics available N2_068_1
95 9787111123549 艺术的故事 E.H. Gombrich Art maintained W4_099_3
96 9787111123550 枪炮、病菌与钢铁 Jared Diamond History available S1_095_3
97 9787111123551 小王子 Antoine de Saint-Exupéry Children's Book borrowed W3_085_4
98 9787111123552 Python编程实战 Eric Matthes Programming available N2_045_3
99 9787111123553 百年孤独 Gabriel García Márquez Literature borrowed S3_078_2
100 9787111123554 人类简史 Yuval Noah Harari History maintained W1_112_4
101 9787111123555 人工智能革命 Thomas H. Cormen AI available N3_023_5
102 9787111123556 唐简史 钱钟书 Literature borrowed S2_056_1
103 9787111123557 量子计算技术前沿 Andrew Ng Science available N1_088_2
104 9787111123558 艺术鉴赏入门 E.H. Gombrich Art maintained W4_099_3
105 9787111123559 被遗忘的春秋战国时代 Jared Diamond History available S3_044_4
106 9787111123560 巴洛克艺术鉴赏 Cao Xueqin Art borrowed N2_033_1
107 9787111123561 机器学习实战 Kevin Murphy AI available W2_066_5
108 9787111123562 三体 刘慈欣 Science Fiction maintained S1_095_3
109 9787111123563 资本论 Karl Marx Economics available N3_017_2
110 9787111123564 活着 余华 Literature borrowed W3_082_4
111 9787111123565 算法导论 Thomas H. Cormen Computer Science maintained N2_033_1
112 9787111123566 时间简史 Stephen Hawking Science available S2_070_3
113 9787111123567 围城 钱钟书 Literature borrowed W4_093_5
114 9787111123568 深度学习 Kevin Murphy AI available N1_102_3
115 9787111123569 枪炮、病菌与钢铁 Jared Diamond History maintained S1_055_2
116 9787111123570 1984 George Orwell Literature available N2_068_1
117 9787111123571 小王子 Antoine de Saint-Exupéry Children's Book borrowed W3_085_4
118 9787111123572 人类简史 Yuval Noah Harari History available S2_088_5
119 9787111123573 Python基础教程 Eric Matthes Programming maintained W4_096_3
120 9787111123574 艺术的故事 E.H. Gombrich Art available S1_077_4
121 9787111123575 经济转型与政策分析 N. Gregory Mankiw Economics borrowed N2_048_5
122 9787111123576 傲慢与偏见 Jane Austen Literature available N1_045_3
123 9787111123577 量子力学导论 David Griffiths Science maintained S3_066_2
124 9787111123578 红楼梦 Cao Xueqin Literature borrowed W4_099_5
125 9787111123579 机器学习实战 Andrew Ng AI available S2_033_1
126 9787111123580 活着 余华 Literature maintained N3_055_3
127 9787111123581 时间简史 Stephen Hawking Science available S3_095_3
128 9787111123582 1984 George Orwell Literature borrowed N2_068_1
129 9787111123583 三体 刘慈欣 Science Fiction maintained W3_100_5
130 9787111123584 枪炮、病菌与钢铁 Jared Diamond History available S1_095_3
131 9787111123585 围城 钱钟书 Literature borrowed W4_093_5
132 9787111123586 Python编程从入门到实践 Eric Matthes Programming available N3_077_2
133 9787111123587 艺术与错觉 E.H. Gombrich Art maintained S2_088_2
134 9787111123588 小王子 Antoine de Saint-Exupéry Children's Book available N3_077_3
135 9787111123589 经济转型与政策分析 N. Gregory Mankiw Economics borrowed W4_095_5
136 9787111123590 人类简史 Yuval Noah Harari History available S2_088_3
137 9787111123591 Python基础教程 Eric Matthes Programming maintained W4_096_3
138 9787111123592 活着 余华 Literature borrowed N3_055_3
139 9787111123593 三体 刘慈欣 Science Fiction available W3_100_5
140 9787111123594 算法导论 Thomas H. Cormen Computer Science maintained S2_077_4
141 9787111123595 时间简史 Stephen Hawking Science borrowed S3_095_3
142 9787111123596 资本论 Karl Marx Economics available N2_068_1
143 9787111123597 艺术的故事 E.H. Gombrich Art maintained W4_099_3
144 9787111123598 枪炮、病菌与钢铁 Jared Diamond History available S1_095_3
145 9787111123599 小王子 Antoine de Saint-Exupéry Children's Book borrowed W3_085_4

@ -0,0 +1 @@
isbn,title,author,category,status,place,time,borrower
1 isbn title author category status place time borrower

@ -0,0 +1,64 @@
# calculate.py 文件
import time # 导入时间模块,用于控制计算频率 [3](@ref)
import csv
def main(a, w1):
try:
x = 1
while True:
y = int(a)+x # 将输入字符串转换为整数并计算 [3](@ref)
w1.insert(1.0, str(y)+'\n') # 在文本区域插入计算结果 [3](@ref)
time.sleep(1) # 暂停1秒控制刷新频率 [3](@ref)
x += 1
except Exception:
w1.insert(1.0, '请输入数字\n') # 捕获异常并提示用户 [3](@ref)
def query_isbn(isbn, csv_path='datas/books.csv'):
"""
同步查询ISBN信息直接返回结果
:param isbn: ISBN编号字符串
:param csv_path: CSV文件路径
:return: 匹配记录列表或错误信息字符串
"""
try:
with open(csv_path, 'r', encoding='utf-8') as f:
reader = csv.DictReader(f)
results = []
for row in reader:
if row['isbn'].strip() == isbn.strip():
results.append(row)
return results if results else ["未找到匹配的图书记录"]
except FileNotFoundError:
return [f"错误:文件 {csv_path} 不存在"]
except Exception as e:
return [f"查询失败:{str(e)}"]
def fuzzy_search_book(keyword, csv_path='datas/books.csv'):
"""
模糊搜索图书信息
:param keyword: 搜索关键词
:param csv_path: CSV文件路径
:return: 匹配记录列表或错误信息字符串
"""
try:
with open(csv_path, 'r', encoding='utf-8') as f:
reader = csv.DictReader(f)
results = []
for row in reader:
# 在书名、作者和分类中搜索关键词
if (keyword.lower() in row['title'].lower() or
keyword.lower() in row['author'].lower() or
keyword.lower() in row['category'].lower()):
results.append(row)
return results if results else "未找到匹配的图书记录"
except FileNotFoundError:
return f"错误:文件 {csv_path} 不存在"
except Exception as e:
return f"查询失败:{str(e)}"

File diff suppressed because one or more lines are too long

210
ui.py

@ -0,0 +1,210 @@
# ui.py 文件
import tkinter as tk
import threading
import sys
sys.path.append(r"./datas")
from calculate import *
class GUI:
def __init__(self):
self.root = tk.Tk()
self.root.title('图书查询系统')
self.root.geometry("600x800")
self.root.configure(bg='#f0f0f0')
self.create_widgets()
self.setup_layout()
def create_widgets(self):
"""创建所有界面组件"""
# 主框架
self.main_frame = tk.Frame(self.root, padx=20, pady=20, bg='#f0f0f0')
# 标题
self.title_label = tk.Label(self.main_frame,
text="图书ISBN查询系统",
font=('微软雅黑', 16, 'bold'),
bg='#f0f0f0')
# 输入区域
self.input_frame = tk.Frame(self.main_frame, bg='#f0f0f0')
self.input_label = tk.Label(self.input_frame,
text="请输入ISBN:",
font=('微软雅黑', 10),
bg='#f0f0f0')
self.entry00 = tk.StringVar()
self.entry = tk.Entry(self.input_frame,
textvariable=self.entry00,
font=('微软雅黑', 10),
width=30,
relief=tk.GROOVE,
borderwidth=2)
# 查询按钮
self.query_button = tk.Button(self.main_frame,
text="查询",
command=self.start,
font=('微软雅黑', 10),
bg='#4CAF50',
fg='white',
activebackground='#45a049',
padx=15,
pady=5)
# 结果区域
self.result_frame = tk.Frame(self.main_frame,
bg='white',
relief=tk.GROOVE,
borderwidth=1)
# 添加滚动条
self.scrollbar = tk.Scrollbar(self.result_frame)
self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
# 使用Text组件替代Label以便支持滚动
self.result_text = tk.Text(self.result_frame,
yscrollcommand=self.scrollbar.set,
font=('微软雅黑', 10),
wrap=tk.WORD,
bg='white',
padx=10,
pady=10)
self.result_text.pack(expand=True, fill='both')
self.scrollbar.config(command=self.result_text.yview)
# 初始文本
self.result_text.insert(tk.END, "查询结果将显示在这里...")
self.result_text.config(state=tk.DISABLED) # 设置为只读
# 添加模糊搜索按钮
self.fuzzy_button = tk.Button(self.main_frame,
text="模糊搜索",
command=self.fuzzy_search,
font=('微软雅黑', 10),
bg='#2196F3', # 蓝色按钮
fg='white',
activebackground='#0b7dda',
padx=15,
pady=5)
# 添加模糊搜索输入框
self.fuzzy_entry00 = tk.StringVar()
self.fuzzy_entry = tk.Entry(self.input_frame,
textvariable=self.fuzzy_entry00,
font=('微软雅黑', 10),
width=30,
relief=tk.GROOVE,
borderwidth=2)
def setup_layout(self):
"""设置组件布局"""
self.main_frame.pack(expand=True, fill='both')
self.title_label.pack(pady=(0, 20))
# 输入区域布局
self.input_frame.pack(pady=10)
self.input_label.grid(row=0, column=0, padx=5)
self.entry.grid(row=0, column=1, padx=5)
# 按钮和结果区域
self.query_button.pack(pady=15)
self.result_frame.pack(fill='both', expand=True, pady=(10,0))
# 删除下面这行
# self.result_label.pack(expand=True, fill='both')
# 添加模糊搜索输入框和按钮布局
tk.Label(self.input_frame,
text="模糊搜索:",
font=('微软雅黑', 10),
bg='#f0f0f0').grid(row=1, column=0, padx=5)
self.fuzzy_entry.grid(row=1, column=1, padx=5)
self.fuzzy_button.pack(pady=10)
def fuzzy_search(self):
"""处理模糊搜索按钮点击事件"""
keyword = self.fuzzy_entry00.get().strip()
if not keyword:
self.result_text.config(state=tk.NORMAL)
self.result_text.delete(1.0, tk.END)
self.result_text.insert(tk.END, "请输入搜索关键词")
self.result_text.config(state=tk.DISABLED)
return
self.fuzzy_button.config(state=tk.DISABLED, text="搜索中...")
self.root.update()
try:
results = fuzzy_search_book(keyword)
self.result_text.config(state=tk.NORMAL)
self.result_text.delete(1.0, tk.END)
if isinstance(results, str):
self.result_text.insert(tk.END, results)
else:
formatted_results = "\n\n".join(
"\n".join(f"{k}: {v}" for k, v in book.items())
for book in results
)
self.result_text.insert(tk.END, formatted_results)
self.result_text.config(state=tk.DISABLED)
except Exception as e:
self.result_text.config(state=tk.NORMAL)
self.result_text.delete(1.0, tk.END)
self.result_text.insert(tk.END, f"搜索出错: {str(e)}")
self.result_text.config(state=tk.DISABLED)
finally:
self.fuzzy_button.config(state=tk.NORMAL, text="模糊搜索")
def start(self):
"""处理查询按钮点击事件"""
isbn = self.entry00.get().strip()
if not isbn:
self.result_text.config(state=tk.NORMAL)
self.result_text.delete(1.0, tk.END)
self.result_text.insert(tk.END, "请输入ISBN编号")
self.result_text.config(state=tk.DISABLED)
return
# 禁用按钮防止重复点击
self.query_button.config(state=tk.DISABLED, text="查询中...")
self.root.update() # 强制更新界面
try:
result = query_isbn(isbn)
self.result_text.config(state=tk.NORMAL)
self.result_text.delete(1.0, tk.END)
if isinstance(result, dict):
formatted_result = "\n".join(f"{k}: {v}" for k, v in result.items())
self.result_text.insert(tk.END, formatted_result)
else:
self.result_text.insert(tk.END, result)
self.result_text.config(state=tk.DISABLED)
except Exception as e:
self.result_text.config(state=tk.NORMAL)
self.result_text.delete(1.0, tk.END)
self.result_text.insert(tk.END, f"查询出错: {str(e)}")
self.result_text.config(state=tk.DISABLED)
finally:
# 恢复按钮状态
self.query_button.config(state=tk.NORMAL, text="查询")
def display_results(self, results):
"""以表格形式显示查询结果"""
# 清空原有内容
self.result_text.config(state=tk.NORMAL)
self.result_text.delete(1.0, tk.END)
if isinstance(results, str) or (isinstance(results, list) and len(results) == 1 and isinstance(results[0], str)):
# 处理错误信息
self.result_text.insert(tk.END, results if isinstance(results, str) else results[0])
else:
# 创建表格形式的文本
for book in results:
for key, value in book.items():
self.result_text.insert(tk.END, f"{key}: {value}\n")
self.result_text.insert(tk.END, "\n")
self.result_text.config(state=tk.DISABLED) # 恢复为只读
if __name__ == '__main__':
app = GUI()
app.root.mainloop()

@ -0,0 +1,3 @@
user_id,username,password,is_admin
1,admin,123456,True
2,user01,123456,False
1 user_id username password is_admin
2 1 admin 123456 True
3 2 user01 123456 False

@ -0,0 +1,14 @@
#1实现多次查询
有以下机制:
1. 按钮状态管理
2. 结果区域重置
3. 异常处理机制
4. 输入值获取
这种设计保证了:
- 每次点击查询按钮都会执行完整的查询流程
- 前一次查询不会影响后一次查询
- 即使查询出错,界面也能恢复正常状态
- 用户可以连续进行多次不同的查询操作
整个过程是事件驱动的,每次按钮点击都会触发独立的查询操作,所有状态都会在操作完成后重置,从而支持多次查询。

@ -0,0 +1,3 @@
1.users文件里admin指管理员
2.对象的结构如文件所示其中books最后一个属性位置的编码有待商酌
3.目前实现ui为主程序calculate为计算函数所在的部分将二者分开
Loading…
Cancel
Save