You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.6 KiB
58 lines
1.6 KiB
# main.py
|
|
import tkinter as tk
|
|
from student.dal.csv_student_dal import CsvStudentDAL
|
|
from student.dal.json_student_dal import JsonStudentDAL
|
|
from student.dal.sqlite_student_dal import SQLiteStudentDAL
|
|
from student.bll.student_bll import StudentBLL
|
|
from student.ui.gui_ui import StudentGUI # 修改导入
|
|
import sys
|
|
from pprint import pprint
|
|
pprint(sys.path) # 打印模块搜索路径
|
|
|
|
|
|
def main():
|
|
# 创建主窗口
|
|
root = tk.Tk()
|
|
|
|
# 选择数据存储方式
|
|
storage_choice = tk.StringVar(value="3")
|
|
|
|
# 创建选择对话框
|
|
dialog = tk.Toplevel(root)
|
|
dialog.title("选择数据存储方式")
|
|
dialog.geometry("300x200")
|
|
dialog.transient(root)
|
|
dialog.grab_set()
|
|
|
|
tk.Label(dialog, text="请选择数据存储方式:").pack(pady=10)
|
|
|
|
tk.Radiobutton(dialog, text="CSV文件", variable=storage_choice, value="1").pack(anchor=tk.W, padx=20)
|
|
tk.Radiobutton(dialog, text="JSON文件", variable=storage_choice, value="2").pack(anchor=tk.W, padx=20)
|
|
tk.Radiobutton(dialog, text="SQLite数据库", variable=storage_choice, value="3").pack(anchor=tk.W, padx=20)
|
|
|
|
def on_ok():
|
|
dialog.destroy()
|
|
|
|
tk.Button(dialog, text="确定", command=on_ok).pack(pady=20)
|
|
|
|
# 等待对话框关闭
|
|
root.wait_window(dialog)
|
|
|
|
# 根据选择初始化数据访问层
|
|
if storage_choice.get() == '1':
|
|
dal = CsvStudentDAL()
|
|
elif storage_choice.get() == '2':
|
|
dal = JsonStudentDAL()
|
|
else:
|
|
dal = SQLiteStudentDAL()
|
|
|
|
# 初始化业务逻辑层和用户界面
|
|
bll = StudentBLL(dal)
|
|
app = StudentGUI(root, bll)
|
|
|
|
# 运行主循环
|
|
root.mainloop()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |