gyt200300 5 months ago
parent 1f3696b745
commit 345de4f86a

@ -1,43 +0,0 @@
import tkinter as tk
from tkinter import messagebox
import random
import pymysql
import test
class Window3(tk.Toplevel):
def __init__(self, master):
super().__init__(master)
self.title("易错单词复习")
self.geometry("400x300")
# 数据库连接设置
self.cursor = self.db.cursor()
self.text_widget = tk.Text(self, wrap=tk.WORD, width=40, height=10)
self.text_widget.pack(expand=True, fill=tk.BOTH, padx=10, pady=10)
# 获取易错单词
self.fetch_and_display_mistaken_words()
def fetch_and_display_mistaken_words(self):
self.cursor.execute("SELECT `word`, `meaning` FROM `words` WHERE `easily_mistaken` = 1")
mistaken_words = self.cursor.fetchall()
if mistaken_words:
self.display_words(mistaken_words)
else:
messagebox.showinfo("提示", "没有易错单词可供复习!")
self.destroy()
def display_words(self, words):
# 使用Text控件显示单词和意义
for idx, word_info in enumerate(words, start=1):
text_to_insert = f"{idx}. 单词: {word_info['word']}, 意义: {word_info['meaning']}\n"
self.text_widget.insert(tk.END, text_to_insert)
# 自动滚动到底部
self.text_widget.see(tk.END)
def on_closing(self):
self.db.close()
self.destroy()

@ -1,20 +0,0 @@
import pymysql
def connect_db():
# 数据库连接参数
db_host = 'localhost' # 数据库主机名
db_user = 'root' # 数据库用户名
db_password = '123456' # 数据库密码
db_database = 'user_info' # 数据库名
db_port = 3306 # 数据库端口通常默认为3306
# 创建连接
connection = pymysql.connect(host=db_host,
user=db_user,
password=db_password,
database=db_database,
port=db_port)
cursor = connection.cursor()
return cursor
if __name__ == '__main__':
cursor = connect_db()
print("数据库连接成功!")

@ -1,41 +0,0 @@
import pymysql
# 数据库连接参数
db_config = {
'host': 'localhost', # 数据库地址默认localhost
'port': 3306, # 数据库端口默认3306
'user': 'root', # 数据库用户名
'password': '21412030117', # 数据库密码
'database': 'word', # 要连接的数据库名
'charset': 'utf8mb4', # 字符编码推荐使用utf8mb4支持更多字符集
}
# 尝试建立连接
try:
connection = pymysql.connect(**db_config)
print("连接MySQL数据库成功")
# 创建游标
cursor = connection.cursor()
# 执行SQL查询
sql_query = "SELECT * FROM words"
cursor.execute(sql_query)
# 获取查询结果
results = cursor.fetchall()
for row in results:
print(row)
# 关闭游标和连接
cursor.close()
connection.close()
except pymysql.MySQLError as e:
print(f"连接数据库时发生错误: {e}")

@ -11,6 +11,7 @@ class LoginPage(tk.Toplevel):
self.username_var = tk.StringVar()
self.password_var = tk.StringVar()
self.wrong_attempts = 0 # 记录密码错误次数的计数器
tk.Label(self, text="用户名:").pack()
tk.Entry(self, textvariable=self.username_var).pack()
@ -18,7 +19,7 @@ class LoginPage(tk.Toplevel):
tk.Label(self, text="密码:").pack()
tk.Entry(self, show="*", textvariable=self.password_var).pack()
tk.Button(self, text="登录", command=self.login).pack(pady=10)
tk.Button(self, text="开始学习", command=self.login).pack(pady=10)
def login(self):
username = self.username_var.get()
@ -27,8 +28,11 @@ class LoginPage(tk.Toplevel):
self.master.destroy() # 关闭主窗口(如果有),这里假设直接关闭自身也行,取决于实际结构
MainApp().mainloop() # 登录成功后实例化MainApp并启动其主循环
else:
messagebox.showerror("错误", "用户名或密码错误!") # 登录失败,保持登录界面打开供用户重试
self.wrong_attempts += 1 # 每次密码错误计数器加1
messagebox.showerror("错误", "用户名或密码错误!")
if self.wrong_attempts >= 3: # 检查错误次数是否达到限制
messagebox.showerror("警告", "密码错误次数过多,程序即将退出。")
self.quit() # 退出程序
class MainApp(tk.Tk):
@ -70,12 +74,11 @@ class Window1(tk.Toplevel):
self.cursor = self.conn.cursor()
self.word_frame = tk.Frame(self)
self.word_frame.pack(padx=10, pady=10)
self.word_frame.pack(padx=20, pady=20)
self.next_button = tk.Button(self, text="下一个单词", command=self.show_next_word)
self.next_button.pack(side=tk.RIGHT, padx=5, pady=5)
self.prev_button = tk.Button(self, text="上一个单词") # 实现逻辑待补充
self.prev_button.pack(side=tk.LEFT, padx=5, pady=5)
self.show_next_word() # 初始显示一个单词
@ -177,7 +180,7 @@ class Window2(tk.Toplevel):
self.word_error_count[self.current_word] = 1
# 达到错误次数限制时更新数据库
if self.word_error_count[self.current_word] > 3:
if self.word_error_count[self.current_word] > 2:
self.update_easily_mistaken_in_db()
def update_easily_mistaken_in_db(self):

@ -0,0 +1,118 @@
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('abandon', 'v. 抛弃,放弃', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('abnormal', 'adj.不正常的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('absurd', 'adj.荒谬的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('abundant', 'adj.丰富的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('acknowledgement', 'n. 承认,感谢,致谢', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('acute', 'adj.敏锐的,锋利的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('admiration', 'n. 欣赏', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('advocate', 'n. 提倡者,拥护者', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('allowance', 'n. 津贴', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('ambition', 'n. 野心,雄心', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('analogy', 'n. 相似,模拟,类比', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('anticipation', 'n. 预期,期望', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('applaud', 'v. 赞扬,称赞', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('appreciation', 'n. 感谢,感激', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('appropriate', 'adj.合适的,恰当的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('array', 'n. 陈列,一系列', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('ascend', 'v. 上升,攀登', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('assurance', 'n. 保证', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('attribute', 'v. 归因于', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('average', 'adj.一般的,普通的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('barren', 'adj.贫瘠的,不毛的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('base', 'v. 建立在……的基础上', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('bewilder', 'v. 迷惑,弄糊涂', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('bound', 'adj.一定的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('breed', 'v. 培育,养育', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('chronic', 'adj.慢性的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('circulation', 'n. (书报等的)发行量', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('cling', 'v. 坚守,抱紧', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('coincide', 'v. 相同,相一致', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('collaborate', 'v. 合著,合作', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('commentary', 'adj.实况报道', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('commitment', 'n. 承诺,许诺', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('compact', 'adj.紧凑的,小巧的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('confront', 'v. 面对,面临', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('conserve', 'v. 保护,保存', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('decent', 'adj.体面的,像样的,还不错的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('deliberately', 'adv. 故意,有意地', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('delicate', 'adj.精细的,微妙的,精心处理的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('destructive', 'adj.毁灭的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('economic', 'adj.经济的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('elegant', 'adj.优雅的,优美的,精致的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('embarrassing', 'adj.令人尴尬的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('energetic', 'adj.精力充沛的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('estimate', 'n. 估计', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('exclusively', 'adv. 仅仅地', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('explicitly', 'adv. 明确地', '1', '1');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('extinct', 'adj.灭绝的,绝种的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('fatal', 'adj.致命的,毁灭性的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('forcibly', 'adv. 强行地,有力地', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('formerly', 'adv. 原先地,以前,从前', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('gloomy', 'adj.暗淡的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('greasy', 'adj.油腻的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('guarantee', 'n. 保修单', '1', '1');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('guilt', 'n. 内疚,罪行', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('harmony', 'n. 与……协调一致,和谐', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('hospitality', 'n. 友好款待,好客', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('humor', 'n. 情绪,心境', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('identical', 'adj.相同的,一样的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('illusion', 'n. 错觉,假象', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('imaginative', 'adj.富有想象力的,爱想象的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('increasingly', 'adv. 日益,越来越多地', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('inevitably', 'adv. 必然地,不可避免地', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('inferior', 'adj.地位较低的,较差的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('ingredient', 'n. 成分', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('inherent', 'adj.固有的,生来的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('insight', 'n. 理解,洞察力', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('inspection', 'n. 检查,视察', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('massive', 'adj.大规模的,大量的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('misfortune', 'n. 不幸,灾难', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('morality', 'n. 道德,美德', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('notion', 'n. 概念,观念,理解', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('notorious', 'adj.臭名昭著的,声名狼藉的', '1', '1');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('obedient', 'adj.服从的,顺从的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('obligation', '(法律上或道义上的)责任', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('occasion', 'n. 场合', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('opponent', 'n. 敌人,对手', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('ornament', 'n. 装饰,装饰品', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('outwardly', 'adv. 表面上,外表上地', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('participation', 'n. 参加,加入', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('persistent', 'adj.坚持不懈的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('personality', 'n. 人格,人性', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('pledge', 'n. 保证,誓言', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('position', 'n. 位置,职位,职务', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('potential', 'adj.可能的,潜在的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('predecessor', 'n. 前任,原有的事物', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('prestige', 'n. 威信,威望', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('presumably', 'adv. 大概,可能,据推测', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('priority', 'n. 优先(权)', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('profound', 'adj.深刻的,深远的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('prominent', 'adj.突出的,杰出的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('prompt', 'adj.即刻的,迅速的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('prospect', 'n. 前景,可能性', '1', '1');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('rate', 'n. 速度', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('ration', 'n. 比率', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('raw', 'adj.自然状态的,未加工的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('recession', 'n. (经济)衰退,不景气;撤退,退出', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('relevant', 'adj.与……有关的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('respectable', 'adj.可尊敬的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('rough', 'adj.粗略的,不精确的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('rude', 'adj.粗鲁的,不礼貌的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('sensitive', 'adj.敏感的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('simultaneously', 'adv. 同时发生地', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('somewhat', 'adv. 颇为,稍稍,有几分', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('subtle', 'adj.微妙的,精巧的,细微的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('temperament', 'n. 气质,性格', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('threshold', 'n. 开端,入口', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('trend', 'n. 倾向,趋势', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('triumphantly', '(欣喜)胜利地,成功地', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('unexpectedly', 'adv. 意外地', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('variation', 'n. 变化,变动', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('versatile', 'adj.多才多艺的', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('virtually', 'adv. 事实上,实际地', '1', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('vivid', 'adj.生动的,栩栩如生的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('void', 'adj.无效的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('vulnerable', 'adj. 易受伤的', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('warehouse', 'n. 货仓', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('way', 'n. 方式', '0', '0');
INSERT INTO `words` (`word`, `meaning`, `learned`, `easily_mistaken`) VALUES ('worth', 'adj. 值得', '1', '0');
Loading…
Cancel
Save