改进
This commit is contained in:
@@ -9,9 +9,11 @@ from typing import Tuple, Dict
|
||||
import particles as pt
|
||||
import puzzles as pz
|
||||
import re
|
||||
import random
|
||||
import copy
|
||||
|
||||
class Composition():
|
||||
def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]):
|
||||
def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict] = pt.Atom.placeholder()):
|
||||
self.screen = screen
|
||||
self.atom = atom
|
||||
from reactor import Reactor
|
||||
@@ -30,10 +32,17 @@ class Composition():
|
||||
yield Label("示例标签", id="testlabel")
|
||||
yield Button("示例按钮", id="testbtn")
|
||||
def handler(self, event, type_):
|
||||
if hasattr(event, "button"):
|
||||
return 1
|
||||
#if hasattr(event, "button"):
|
||||
#print(event.button.id)
|
||||
self.screen.query_one("#testlabel", Label).update("hi")
|
||||
# self.screen.query_one("#testlabel", Label).update("hi")
|
||||
|
||||
class Finished(Composition):
|
||||
def __init__(self, screen: Screen, reactor, atom: Tuple[pt.Electron, pt.Nucleon, Dict]):
|
||||
super().__init__(screen, reactor, atom)
|
||||
def compose(self):
|
||||
yield Label("本次记忆进程结束", id=self.regid("msg"))
|
||||
#yield Button("示例按钮", id="testbtn")
|
||||
class Placeholder(Composition):
|
||||
def __init__(self, screen: Screen):
|
||||
self.screen = screen
|
||||
@@ -128,7 +137,11 @@ class FillBlank(Composition):
|
||||
self.puzzle.refresh()
|
||||
def compose(self):
|
||||
self._work()
|
||||
yield Label(self.puzzle.wording, id="sentence")
|
||||
yield Label(self.puzzle.wording, id=self.regid("sentence"))
|
||||
ans = copy.copy(self.puzzle.answer)
|
||||
random.shuffle(ans)
|
||||
for i in ans:
|
||||
yield
|
||||
yield Button("我已知晓", id="ok")
|
||||
def handler(self, event, type_):
|
||||
if event.button.id == "ok":
|
||||
|
@@ -3,6 +3,6 @@ save = 1
|
||||
# [调试] 覆写时间
|
||||
time_override = 10
|
||||
# 对于每个项目的新记忆核子数量
|
||||
tasked_number = 12
|
||||
tasked_number = 8
|
||||
# 竖屏适配
|
||||
mobile_mode = 1
|
@@ -6,7 +6,7 @@ interval = 1
|
||||
last_date = 10
|
||||
next_date = 11
|
||||
is_activated = 1
|
||||
last_modify = 1754241563.9242582
|
||||
last_modify = 1754244217.8045535
|
||||
|
||||
["生孩/六月/, 慈父/见背/; /行年/四岁/, 舅/夺/母志./"]
|
||||
efactor = 2.5
|
||||
@@ -16,7 +16,7 @@ interval = 1
|
||||
last_date = 10
|
||||
next_date = 11
|
||||
is_activated = 1
|
||||
last_modify = 1754241564.467116
|
||||
last_modify = 1754244218.3349776
|
||||
|
||||
["祖母/刘/愍/臣/孤弱/, 躬亲/抚养./"]
|
||||
efactor = 2.5
|
||||
@@ -26,7 +26,7 @@ interval = 1
|
||||
last_date = 10
|
||||
next_date = 11
|
||||
is_activated = 1
|
||||
last_modify = 1754241565.3159063
|
||||
last_modify = 1754244218.9444783
|
||||
|
||||
["臣/少/多/疾病/, 九岁/不行/, 零丁/孤苦/, 至于/成立./"]
|
||||
efactor = 2.5
|
||||
@@ -36,7 +36,7 @@ interval = 1
|
||||
last_date = 10
|
||||
next_date = 11
|
||||
is_activated = 1
|
||||
last_modify = 1754241566.100317
|
||||
last_modify = 1754244219.28863
|
||||
|
||||
["既/无/伯叔/, 终/鲜/兄弟/, 门/衰/祚/薄/, 晚/有/儿息./"]
|
||||
efactor = 2.5
|
||||
@@ -46,7 +46,7 @@ interval = 1
|
||||
last_date = 10
|
||||
next_date = 11
|
||||
is_activated = 1
|
||||
last_modify = 1754241566.9799266
|
||||
last_modify = 1754244219.6544538
|
||||
|
||||
["外/无/期功/强近/之亲/, 内/无/应门/五尺/之僮/, 茕茕/孑立/, 形影/相吊./"]
|
||||
efactor = 2.5
|
||||
@@ -56,7 +56,7 @@ interval = 1
|
||||
last_date = 10
|
||||
next_date = 11
|
||||
is_activated = 1
|
||||
last_modify = 1754241567.6606886
|
||||
last_modify = 1754244220.0074852
|
||||
|
||||
["而/刘/夙/婴/疾病/, 常/在/床蓐/, 臣/侍/汤药/, 未曾/废离./"]
|
||||
efactor = 2.5
|
||||
@@ -66,57 +66,57 @@ interval = 1
|
||||
last_date = 10
|
||||
next_date = 11
|
||||
is_activated = 1
|
||||
last_modify = 1754241568.2600803
|
||||
last_modify = 1754244220.3606052
|
||||
|
||||
["逮/奉/圣朝/, 沐浴/清化./"]
|
||||
efactor = 2.5
|
||||
real_rept = 2
|
||||
real_rept = 17
|
||||
rept = 0
|
||||
interval = 1
|
||||
last_date = 10
|
||||
next_date = 11
|
||||
is_activated = 1
|
||||
last_modify = 1754241568.6842272
|
||||
last_modify = 1754244226.386384
|
||||
|
||||
["前/太守/臣/逵/察/臣/孝廉/; /后/刺史/臣/荣/举/臣/秀才./"]
|
||||
efactor = 2.5
|
||||
real_rept = 2
|
||||
real_rept = 0
|
||||
rept = 0
|
||||
interval = 1
|
||||
last_date = 10
|
||||
next_date = 11
|
||||
is_activated = 1
|
||||
last_modify = 1754241569.060461
|
||||
interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754244183.007183
|
||||
|
||||
["臣/以/供养/无主/, 辞/不赴命./"]
|
||||
efactor = 2.5
|
||||
real_rept = 2
|
||||
real_rept = 0
|
||||
rept = 0
|
||||
interval = 1
|
||||
last_date = 10
|
||||
next_date = 11
|
||||
is_activated = 1
|
||||
last_modify = 1754241569.4603384
|
||||
interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754244183.0071847
|
||||
|
||||
["诏书/特下/, 拜/臣/郎中/, 寻/蒙/国恩/, 除/臣/洗马./"]
|
||||
efactor = 2.5
|
||||
real_rept = 2
|
||||
real_rept = 0
|
||||
rept = 0
|
||||
interval = 1
|
||||
last_date = 10
|
||||
next_date = 11
|
||||
is_activated = 1
|
||||
last_modify = 1754241569.8361027
|
||||
interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754244183.0071867
|
||||
|
||||
["猥/以/微贱/, 当/侍/东宫/, 非/臣/陨首/所能/上报./"]
|
||||
efactor = 2.5
|
||||
real_rept = 6
|
||||
real_rept = 0
|
||||
rept = 0
|
||||
interval = 1
|
||||
last_date = 10
|
||||
next_date = 11
|
||||
is_activated = 1
|
||||
last_modify = 1754241571.6039598
|
||||
interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754244183.0071883
|
||||
|
||||
["臣/具/以表/闻/, 辞/不就职./"]
|
||||
efactor = 2.5
|
||||
@@ -126,7 +126,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.0075471
|
||||
last_modify = 1754244183.0071898
|
||||
|
||||
["诏书/切峻/, 责/臣/逋慢/; /郡县/逼迫/, 催/臣/上道/; /州司/临门/, 急于/星火./"]
|
||||
efactor = 2.5
|
||||
@@ -136,7 +136,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.007548
|
||||
last_modify = 1754244183.007191
|
||||
|
||||
["臣/欲/奉诏/奔驰/, 则/刘/病/日笃/, 欲/苟/顺/私情/, 则/告诉/不许./"]
|
||||
efactor = 2.5
|
||||
@@ -146,7 +146,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.0075495
|
||||
last_modify = 1754244183.0071924
|
||||
|
||||
["臣/之/进退/, 实为/狼狈./"]
|
||||
efactor = 2.5
|
||||
@@ -156,7 +156,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.0075507
|
||||
last_modify = 1754244183.0071936
|
||||
|
||||
["伏惟/圣朝/以/孝/治/天下/, 凡/在/故老/, 犹/蒙/矜育/, 况/臣/孤苦/, 特为/尤甚./"]
|
||||
efactor = 2.5
|
||||
@@ -166,7 +166,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.0075517
|
||||
last_modify = 1754244183.007195
|
||||
|
||||
["且/臣/少/仕/伪朝/, 历职/郎署/, 本图/宦达/, 不矜/名节./"]
|
||||
efactor = 2.5
|
||||
@@ -176,7 +176,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.0075529
|
||||
last_modify = 1754244183.0071962
|
||||
|
||||
["今/臣/亡国/贱俘/, 至微/至陋/, 过/蒙/拔擢/, 宠命/优渥/, 岂敢/盘桓/, 有所/希冀!/"]
|
||||
efactor = 2.5
|
||||
@@ -186,7 +186,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.0075538
|
||||
last_modify = 1754244183.0071974
|
||||
|
||||
["但/以/刘/日薄/西山/, 气息/奄奄/, 人命/危浅/, 朝不/虑夕./"]
|
||||
efactor = 2.5
|
||||
@@ -196,7 +196,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.0075545
|
||||
last_modify = 1754244183.0072057
|
||||
|
||||
["臣/无/祖母/, 无以/至今日/, 祖母/无/臣/, 无以/终余年./"]
|
||||
efactor = 2.5
|
||||
@@ -206,7 +206,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.0075557
|
||||
last_modify = 1754244183.007207
|
||||
|
||||
["母孙/二人/, 更相/为命/, 是以/区区/不能/废远./"]
|
||||
efactor = 2.5
|
||||
@@ -216,7 +216,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.007557
|
||||
last_modify = 1754244183.0072083
|
||||
|
||||
["臣/密/今年/四十/有四/, 祖母/今年/九十/有六/, 是/臣/尽节/于/陛下/之日/长/, 报养/刘/之日/短./"]
|
||||
efactor = 2.5
|
||||
@@ -226,7 +226,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.007558
|
||||
last_modify = 1754244183.0072105
|
||||
|
||||
["乌鸟/私情/, 愿/乞/终养./"]
|
||||
efactor = 2.5
|
||||
@@ -236,7 +236,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.0075595
|
||||
last_modify = 1754244183.0072117
|
||||
|
||||
["臣/之/辛苦/, 非独/蜀之/人士/及/二州/牧伯/所见/明知/, 皇天/后土/, 实所/共鉴./"]
|
||||
efactor = 2.5
|
||||
@@ -246,7 +246,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.0075607
|
||||
last_modify = 1754244183.0072134
|
||||
|
||||
["愿/陛下/矜悯/愚诚/, 听/臣/微志/, 庶/刘/侥幸/, 保/卒/余年./"]
|
||||
efactor = 2.5
|
||||
@@ -256,7 +256,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.0075655
|
||||
last_modify = 1754244183.0072145
|
||||
|
||||
["臣/生/当/陨首/, 死/当/结草./"]
|
||||
efactor = 2.5
|
||||
@@ -266,7 +266,7 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.007567
|
||||
last_modify = 1754244183.0072162
|
||||
|
||||
["臣/不胜/犬马/怖惧/之情/, 谨/拜表/以闻./"]
|
||||
efactor = 2.5
|
||||
@@ -276,4 +276,4 @@ interval = 0
|
||||
last_date = 0
|
||||
next_date = 0
|
||||
is_activated = 0
|
||||
last_modify = 1754241555.007568
|
||||
last_modify = 1754244183.007218
|
||||
|
20
main.py
20
main.py
@@ -12,6 +12,20 @@ from reactor import Reactor, Apparatus
|
||||
import auxiliary as aux
|
||||
import compositions as compo
|
||||
|
||||
import builtins
|
||||
|
||||
# 保存原始的 open 函数
|
||||
_original_open = builtins.open
|
||||
|
||||
# 定义新的 open 函数,默认使用 UTF-8
|
||||
def _open(*args, **kwargs):
|
||||
if 'encoding' not in kwargs:
|
||||
kwargs['encoding'] = 'utf-8'
|
||||
return _original_open(*args, **kwargs)
|
||||
|
||||
# 替换全局的 open
|
||||
builtins.open = _open
|
||||
|
||||
ver = '0.3.0'
|
||||
|
||||
config = aux.ConfigFile("config.toml")
|
||||
@@ -90,8 +104,10 @@ class MemScreen(Screen):
|
||||
if nxt == -1:
|
||||
if self.reactor.round_set == 0:
|
||||
if self.stage == 4:
|
||||
if config.get("save"):
|
||||
self.reactor.save()
|
||||
#if config.get("save"):
|
||||
#self.reactor.save()
|
||||
self.compo = compo.Finished(self, None, pt.Atom.placeholder())
|
||||
self.refresh_ui()
|
||||
#self._show_finished_screen("今日目标已完成")
|
||||
else:
|
||||
self.reactor.set_round_templated(self.stage)
|
||||
|
@@ -8,10 +8,10 @@ translation = "语句翻译"
|
||||
["testdata"]
|
||||
# 记忆时显示的额外信息
|
||||
additional_inf = ["translation","keyword_note", "note"]
|
||||
# 填空测试
|
||||
fill_blank_test = ["translation"]
|
||||
# 填空测试, content指代键名
|
||||
fill_blank_test = {"from"=["content"], "hint"=["translation"]}
|
||||
# 选择题测试
|
||||
draw_card_test = ["keyword_note"]
|
||||
draw_card_test = {"from"=["keyword_note"]}
|
||||
|
||||
["臣/密/言: /臣/以/险衅/, 夙/遭/闵凶./"]
|
||||
note = []
|
||||
|
@@ -41,7 +41,6 @@ class Reactor():
|
||||
counter = self.tasked_num
|
||||
self.screen = screen
|
||||
self.electron_dict = electron_file.electrons_dict
|
||||
|
||||
def electron_dict_get_fallback(key) -> pt.Electron:
|
||||
value = self.electron_dict.get(key)
|
||||
# 如果值不存在,则设置默认值
|
||||
|
Reference in New Issue
Block a user