From fd2e00e507f7d1b1026b66f97e0eedc6750eef54 Mon Sep 17 00:00:00 2001 From: zy52306tg <2752629612@qq.com> Date: Fri, 31 May 2024 11:27:13 +0800 Subject: [PATCH] commit_0531 --- filesys/__pycache__/login.cpython-39.pyc | Bin 891 -> 1115 bytes filesys/__pycache__/login_next.cpython-39.pyc | Bin 3833 -> 5056 bytes filesys/__pycache__/main.cpython-39.pyc | Bin 2455 -> 1466 bytes filesys/__pycache__/register.cpython-39.pyc | Bin 1169 -> 1328 bytes filesys/__pycache__/sql.cpython-39.pyc | Bin 1399 -> 1327 bytes filesys/login.py | 11 ++- filesys/login_next.py | 66 +++++++++++------- filesys/main.py | 4 +- filesys/register.py | 7 +- filesys/sql.py | 5 +- ...1fc4906f.jpg => null22d2cf8d1fc4906f1.jpg} | Bin 11 files changed, 57 insertions(+), 36 deletions(-) rename filesys/图片/{null22d2cf8d1fc4906f.jpg => null22d2cf8d1fc4906f1.jpg} (100%) diff --git a/filesys/__pycache__/login.cpython-39.pyc b/filesys/__pycache__/login.cpython-39.pyc index 9661be5e815bf38ec7cc640bdfbb65503da3f4cb..cb69b1df01149d30f2d6d95a8b20061592c50f72 100644 GIT binary patch literal 1115 zcmY*ZPfrs;6rY*h?Jk9a2uCrPc&Ue`R8PhjBgT^X1DIg}2t^coXgcD=!!wv_R9{Ckgc>vjTw^*lmk7@>@&aM7nL=5s1AZurCB8LL zjKqs!f?&WLhZ+6`B2XPSkV6EiYZNyyMj+{wCJvyL?DGtkycnsuqApG))U+#`V=-2oE8~{Q#BIDt!W9@6K*6t6?3Sx zKdOi#*mCbg_2uaNbfv53 zee>*RJvK`eTjwVyU5e&Ly|eczQKZ1-{Pb;e|6_JQ60s!7^pZ^bY{g!2eHyGtL%70Y z(pq3ai3whn#uI0bc~UPs#U*Jx=1z&p)WeDpfiH)bUGQ`~&vr}B0t;=|pATeTrR)U` zjdijgqWWF9k1~%5maGnX!Gi1CoQVqe?ULjA(u$}T1m&zLd!ov`xBwmmLJq2o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br zGEY9kq{1k)`6H7hBctqOZ5COzTO9H6xrv#1@$s5$QS2qznRz9tMMdmD+oPC^3v-I3 YfUF{+$?sSU_&^TiU<5)b4sH%c0RAv3+5i9m diff --git a/filesys/__pycache__/sql.cpython-39.pyc b/filesys/__pycache__/sql.cpython-39.pyc index 54489aaf0382b1f074d49358eda1566e03394322..c89a76d67a27f9bb4249c726c2c7ba53ad2f7798 100644 GIT binary patch delta 354 zcmX9(u}T9$5S`iEz1wW=axn-=VH7(P5F&_`jYY5#K_Y0*LL@t4LUKwHAxUF#scb~A z6d`HE&ceTmKGzSimg%D;ppf{)(7Eev7|E~w-@FXxNON)3ZHE1LU92q?j98+}q`8(XXG<<6 JL&eH0gTJC`NOu4L delta 440 zcmZXPO-LI-6vyA2on&Vx*%-GGb7=^Lf_h3XMT*c<>#Y|B>sSaOGok8cjYh$EDY7|~ zf~{fkRBRRM)erPk3f?{R(39jSWDz{rTd#f5qwg{AH}iiV!#k4yq+4-a31s6>-_|ZV z?&A-a^w6Nuhv`0z-h-H|ek2r7$ErcNZ44T^|O80%1 z&I|<4IheuL9|YwgY!s-`HIIxJ;#b&ZG=geoX@>IVyg=Tw1SL|YU^LVDo5we&0^5i( z+G4*k8@;oxFc-b#L$$R$Eg$b3$6JTJpV9UCxA^lx{BgVY>HF=k&9&i&$=;8X>$8Iw z#nGHf)ci_wQDyH?ZZ7*3zxv+PTPqf|DZA0Cw@B==rDoLOuXBmU%6zcebzZGkO=ER_ hDd?h!ZurQP0+kC)qd>s~N{U`maA7l)mcTKV!T%$lcE$hz diff --git a/filesys/login.py b/filesys/login.py index c5b78a6..a89a651 100644 --- a/filesys/login.py +++ b/filesys/login.py @@ -1,7 +1,7 @@ -import tkinter as tk from login_next import * +import main def login_1(): - + global new_window new_window = tk.Tk() new_window.title("欢迎来到登陆成功后的界面") new_window.geometry("300x200") @@ -14,12 +14,14 @@ def login_1(): root.pack() # 创建按钮 + view_image_button = tk.Button(root, text="查看图片信息", command=view_all_images_info) upload_image_button = tk.Button(root, text="上传图片", command=upload_image) download_button = tk.Button(root, text="下载图片", command=download_image) delete_button = tk.Button(root, text="删除图片", command=delete_image) - exit_button = tk.Button(root, text="返回", command=new_window.destroy) + exit_button = tk.Button(root, text="返回", command=login_return_main) # 布局 + view_image_button.pack() upload_image_button.pack() download_button.pack() delete_button.pack() @@ -27,6 +29,9 @@ def login_1(): new_window.mainloop() +def login_return_main(): + new_window.destroy() + main.main() if __name__ == "__main__": login_1() diff --git a/filesys/login_next.py b/filesys/login_next.py index 75308f6..1b83817 100644 --- a/filesys/login_next.py +++ b/filesys/login_next.py @@ -1,6 +1,6 @@ import pymysql.cursors import tkinter as tk -from tkinter import filedialog +from tkinter import filedialog,messagebox import os # 数据库连接参数 @@ -45,42 +45,37 @@ def upload_image(): sql = "INSERT INTO images (filename, content) VALUES (%s, %s)" cursor.execute(sql, (os.path.basename(selected_image_path), pymysql.Binary(image_content))) connection.commit() - print(f"Image '{selected_image_path}' uploaded successfully.") + messagebox.showinfo("上传成功", f"图片路径: '{selected_image_path}' 上传成功.") + except Exception as e: + messagebox.showerror("上传错误", f"图片上传失败: {e}") finally: connection.close() def delete_image(): + view_all_images_info() # 获取用户输入的图像ID image_id = tk.simpledialog.askinteger("删除图片", "请输入需要删除的图像ID:") if image_id is not None: connection = pymysql.connect(host=DB_HOST, user=DB_USER, password=DB_PASSWORD, db=DB_NAME) try: with connection.cursor() as cursor: - # 查询图像信息 - cursor.execute("SELECT * FROM images WHERE id = %s", (image_id,)) - image_data = cursor.fetchone() - if image_data: - # 输出图像信息 - print(f"Image Details:") - for index, value in enumerate(image_data): - column_name = cursor.description[index][0] - print(f"{column_name}: {value}") - # 提示用户确认删除 - confirmation = tk.messagebox.askyesno("Confirm Delete", f"是否删除图片ID为 {image_id}的图片?") - if confirmation: - # 执行删除操作 - sql = "DELETE FROM images WHERE id = %s" - cursor.execute(sql, (image_id,)) - connection.commit() - print(f"成功删除图片ID为 {image_id} 的图片.") + # 直接执行删除操作 + cursor.execute("DELETE FROM images WHERE id = %s", (image_id,)) + connection.commit() + + # 提示用户确认删除 + confirmation = tk.messagebox.askyesno("Confirm Delete", f"是否删除图片ID为 {image_id}的图片?") + if confirmation: + messagebox.showinfo("删除成功", f"成功删除图片ID为 {image_id} 的图片.") else: - print(f"没有发现图片ID为 {image_id}的图片.") + messagebox.showinfo("操作取消", "图片删除操作已取消。") except Exception as e: - print(f"Error deleting image: {e}") + messagebox.showerror("删除错误", f"图片删除失败: {e}") finally: connection.close() def download_image(): + view_all_images_info() # 获取用户输入的图像ID image_id = tk.simpledialog.askinteger("下载图片", "请输入需要下载的图像ID:") if image_id is not None: @@ -100,18 +95,37 @@ def download_image(): try: with open(save_path, 'wb') as image_file: image_file.write(content) - print(f"Image downloaded successfully to '{save_path}'.") + messagebox.showinfo("成功", f"图片已成功下载到 '{save_path}'。") except IOError as e: - print(f"Error writing to file: {e}") + messagebox.showerror("错误", f"写入文件时出错: {e}") else: - print("Download cancelled.") + messagebox.showinfo("取消", "下载已取消。") else: - print(f"No image found with ID {image_id}.") + messagebox.showinfo("未找到", f"未找到ID为 {image_id} 的图片。") except Exception as e: - print(f"Error downloading image: {e}") + messagebox.showerror("下载错误", f"下载图片时发生错误: {e}") finally: connection.close() +def view_all_images_info(): + connection = pymysql.connect(host=DB_HOST, user=DB_USER, password=DB_PASSWORD, db=DB_NAME) + try: + with connection.cursor() as cursor: + # 查询所有图片信息 + cursor.execute("SELECT id, filename FROM images") + image_data = cursor.fetchall() + if image_data: + # 构建信息消息 + message = "全部图片信息:\n\n" + for row in image_data: + message += f"Image ID: {row[0]}\nImage Name: {row[1]}\n---\n" + messagebox.showinfo("所有图片信息", message) + else: + messagebox.showinfo("未找到图片", "数据库中没有图片信息。") + except Exception as e: + messagebox.showerror("查询错误", f"Error fetching image info: {e}") + finally: + connection.close() diff --git a/filesys/main.py b/filesys/main.py index d8de539..264f882 100644 --- a/filesys/main.py +++ b/filesys/main.py @@ -1,6 +1,5 @@ from register import * from login import * -import os def main(): global root @@ -46,10 +45,11 @@ def register_jc(): root.destroy() register() - def login_jc(): root.destroy() login_1() + + if __name__ == "__main__": main() diff --git a/filesys/register.py b/filesys/register.py index 50c38c5..4be04a8 100644 --- a/filesys/register.py +++ b/filesys/register.py @@ -1,5 +1,6 @@ import tkinter as tk from sql import * +import main def register(): global register_view @@ -21,7 +22,7 @@ def register(): register_button = tk.Button(register_view, text="注册", command=register_0) register_button.pack() - back_button = tk.Button(register_view, text="返回", command=register_view.destroy) + back_button = tk.Button(register_view, text="返回", command=register_return_main) back_button.pack() register_view.mainloop() @@ -37,5 +38,9 @@ def register_0(): ok_label = tk.Label(register_view, text="注册成功") ok_label.pack() +def register_return_main(): + register_view.destroy() + main.main() + if __name__ == "__main__": register() \ No newline at end of file diff --git a/filesys/sql.py b/filesys/sql.py index 6b4745a..1d45333 100644 --- a/filesys/sql.py +++ b/filesys/sql.py @@ -1,7 +1,5 @@ from flask import * from flask_sqlalchemy import SQLAlchemy -import pymysql -import os app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:123456@localhost:3306/file' @@ -24,12 +22,11 @@ def add_user(username, password): db.session.commit() + try: with app.app_context(): - # 尝试连接数据库 db.create_all() - print("数据库连接成功!") except Exception as e: print(f"数据库连接失败: {str(e)}") diff --git a/filesys/图片/null22d2cf8d1fc4906f.jpg b/filesys/图片/null22d2cf8d1fc4906f1.jpg similarity index 100% rename from filesys/图片/null22d2cf8d1fc4906f.jpg rename to filesys/图片/null22d2cf8d1fc4906f1.jpg