-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
508 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>MainWindow</class> | ||
<widget class="QMainWindow" name="MainWindow"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>600</width> | ||
<height>363</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>弹窗背单词</string> | ||
</property> | ||
<widget class="QWidget" name="centralwidget"> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<property name="spacing"> | ||
<number>10</number> | ||
</property> | ||
<property name="leftMargin"> | ||
<number>10</number> | ||
</property> | ||
<property name="topMargin"> | ||
<number>10</number> | ||
</property> | ||
<property name="rightMargin"> | ||
<number>10</number> | ||
</property> | ||
<property name="bottomMargin"> | ||
<number>10</number> | ||
</property> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<property name="spacing"> | ||
<number>10</number> | ||
</property> | ||
<item> | ||
<widget class="QLabel" name="choose_dict_label"> | ||
<property name="text"> | ||
<string>选择词库</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QComboBox" name="choose_dict"/> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="start_button"> | ||
<property name="text"> | ||
<string>开始</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout_2"> | ||
<item> | ||
<widget class="QLabel" name="label"> | ||
<property name="text"> | ||
<string>查单词</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QLineEdit" name="word_input"/> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="search_button"> | ||
<property name="text"> | ||
<string>查询</string> | ||
</property> | ||
<property name="shortcut"> | ||
<string>Return</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Form implementation generated from reading ui file 'd:\Code\Python\PyQt\vocabulary_learning\MainWindow.ui' | ||
# | ||
# Created by: PyQt5 UI code generator 5.15.11 | ||
# | ||
# WARNING: Any manual changes made to this file will be lost when pyuic5 is | ||
# run again. Do not edit this file unless you know what you are doing. | ||
|
||
|
||
from PyQt5 import QtCore, QtGui, QtWidgets | ||
|
||
|
||
class Ui_MainWindow(object): | ||
def setupUi(self, MainWindow): | ||
MainWindow.setObjectName("MainWindow") | ||
MainWindow.resize(600, 363) | ||
self.centralwidget = QtWidgets.QWidget(MainWindow) | ||
self.centralwidget.setObjectName("centralwidget") | ||
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) | ||
self.verticalLayout.setContentsMargins(10, 10, 10, 10) | ||
self.verticalLayout.setSpacing(10) | ||
self.verticalLayout.setObjectName("verticalLayout") | ||
self.horizontalLayout = QtWidgets.QHBoxLayout() | ||
self.horizontalLayout.setSpacing(10) | ||
self.horizontalLayout.setObjectName("horizontalLayout") | ||
self.choose_dict_label = QtWidgets.QLabel(self.centralwidget) | ||
self.choose_dict_label.setObjectName("choose_dict_label") | ||
self.horizontalLayout.addWidget(self.choose_dict_label) | ||
self.choose_dict = QtWidgets.QComboBox(self.centralwidget) | ||
self.choose_dict.setObjectName("choose_dict") | ||
self.horizontalLayout.addWidget(self.choose_dict) | ||
self.start_button = QtWidgets.QPushButton(self.centralwidget) | ||
self.start_button.setObjectName("start_button") | ||
self.horizontalLayout.addWidget(self.start_button) | ||
self.verticalLayout.addLayout(self.horizontalLayout) | ||
self.horizontalLayout_2 = QtWidgets.QHBoxLayout() | ||
self.horizontalLayout_2.setObjectName("horizontalLayout_2") | ||
self.label = QtWidgets.QLabel(self.centralwidget) | ||
self.label.setObjectName("label") | ||
self.horizontalLayout_2.addWidget(self.label) | ||
self.word_input = QtWidgets.QLineEdit(self.centralwidget) | ||
self.word_input.setObjectName("word_input") | ||
self.horizontalLayout_2.addWidget(self.word_input) | ||
self.search_button = QtWidgets.QPushButton(self.centralwidget) | ||
self.search_button.setObjectName("search_button") | ||
self.horizontalLayout_2.addWidget(self.search_button) | ||
self.verticalLayout.addLayout(self.horizontalLayout_2) | ||
MainWindow.setCentralWidget(self.centralwidget) | ||
|
||
self.retranslateUi(MainWindow) | ||
QtCore.QMetaObject.connectSlotsByName(MainWindow) | ||
|
||
def retranslateUi(self, MainWindow): | ||
_translate = QtCore.QCoreApplication.translate | ||
MainWindow.setWindowTitle(_translate("MainWindow", "弹窗背单词")) | ||
self.choose_dict_label.setText(_translate("MainWindow", "选择词库")) | ||
self.start_button.setText(_translate("MainWindow", "开始")) | ||
self.label.setText(_translate("MainWindow", "查单词")) | ||
self.search_button.setText(_translate("MainWindow", "查询")) | ||
self.search_button.setShortcut(_translate("MainWindow", "Return")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import datetime | ||
from queue import PriorityQueue | ||
from PyQt5 import QtCore, QtGui, QtWidgets, uic | ||
from PyQt5.QtCore import Qt | ||
from PyQt5.QtGui import QFont, QKeySequence | ||
from PyQt5.QtWidgets import ( | ||
QApplication, | ||
QMainWindow, | ||
QComboBox, | ||
QWidget, | ||
QHBoxLayout, | ||
QVBoxLayout, | ||
QLabel, | ||
QMessageBox, | ||
QPushButton, | ||
QShortcut, | ||
) | ||
from utils import c2j, get_translation, j2c, load_dictionary | ||
|
||
|
||
class WordMessageBox(QMessageBox): | ||
def __init__(self, main_window, word): | ||
super().__init__() | ||
self.main_window = main_window | ||
word_history = main_window.history["data"][word] | ||
# 设置标题和内容 | ||
self.setWindowTitle( | ||
f"熟练度:{word_history['level']}" | ||
+ f" 记忆次数:{word_history['count']}" | ||
+ f" 正确率:{ word_history['correct'] / word_history['count'] * 100 if word_history['count'] > 0 else 0 :.0f}%" | ||
) | ||
self.setText(word) | ||
# 添加认识和忘记按钮 | ||
self.setStandardButtons(WordMessageBox.Ok | WordMessageBox.Cancel) | ||
self.button(WordMessageBox.Ok).setText("认识(←)") | ||
self.button(WordMessageBox.Cancel).setText("忘记(→)") | ||
# 添加查看翻译的按钮 | ||
self.translate_button = self.addButton("翻译(↑)", WordMessageBox.ActionRole) | ||
# 添加加入收藏夹的按钮 | ||
self.favorite_button = self.addButton( | ||
"取消收藏(↓)" if word in main_window.favorite else "收藏(↓)", WordMessageBox.ActionRole | ||
) | ||
# 设置消息框始终置顶 | ||
self.setWindowFlags(Qt.WindowStaysOnTopHint) | ||
# 设置字体大小 | ||
font = QFont() | ||
font.setPointSize(18) | ||
font.setFamily("Microsoft YaHei") | ||
self.setFont(font) | ||
# 设置快捷键 | ||
ok_shortcut = QShortcut(QKeySequence(Qt.Key_Left), self) | ||
cancel_shortcut = QShortcut(QKeySequence(Qt.Key_Right), self) | ||
translate_shortcut = QShortcut(QKeySequence(Qt.Key_Up), self) | ||
favorite_shortcut = QShortcut(QKeySequence(Qt.Key_Down), self) | ||
# 绑定快捷键到按钮的点击事件 | ||
ok_shortcut.activated.connect(self.button(WordMessageBox.Ok).click) | ||
cancel_shortcut.activated.connect(self.button(WordMessageBox.Cancel).click) | ||
translate_shortcut.activated.connect(self.translate_button.click) | ||
favorite_shortcut.activated.connect(self.favorite_button.click) | ||
|
||
# 关闭窗口 | ||
def closeEvent(self, event): | ||
print(f"{datetime.datetime.now()} Save and quit.") | ||
self.main_window.running = False | ||
self.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
[ | ||
"vehicle", | ||
"proof", | ||
"factor", | ||
"misuse", | ||
"tackle ", | ||
"trust", | ||
"legal", | ||
"viewpoint", | ||
"manufacturer", | ||
"involve", | ||
"confuse", | ||
"implication", | ||
"consent", | ||
"fatigue", | ||
"distract", | ||
"annoye", | ||
"motion", | ||
"limitation", | ||
"obtain", | ||
"protect", | ||
"automaker", | ||
"liability", | ||
"malfucation", | ||
"capability", | ||
"rely", | ||
"interpeter", | ||
"guarantee", | ||
"protein", | ||
"blend up", | ||
"grab", | ||
"contrary", | ||
"deficiency", | ||
"retail", | ||
"supplement", | ||
"adequate", | ||
"calories", | ||
"intake", | ||
"desirable", | ||
"deaddicated", | ||
"athlete", | ||
"exceed", | ||
"gram", | ||
"strain", | ||
"kidney", | ||
"spotlight", | ||
"firm", | ||
"beverage", | ||
"saturated", | ||
"consumption", | ||
"regain", | ||
"nutrient", | ||
"antioxidant", | ||
"vegetarian", | ||
"realistic", | ||
"flexible", | ||
"imitate", | ||
"suprising", | ||
"struggle", | ||
"trial", | ||
"dozen", | ||
"investigate", | ||
"detect", | ||
"synthetic", | ||
"security", | ||
"vision", | ||
"achievable", | ||
"assume", | ||
"lack", | ||
"strategy", | ||
"deliberate", | ||
"prioritize", | ||
"inaction", | ||
"claim", | ||
"mere", | ||
"procrastination" | ||
] |
Oops, something went wrong.