You've already forked HeurAMS-legacy
fix: 改进
This commit is contained in:
@@ -23,7 +23,7 @@ logger = get_logger(__name__)
|
||||
class MemScreen(Screen):
|
||||
BINDINGS = [
|
||||
("q", "pop_screen", "返回"),
|
||||
("p", "prev", "复习上一个"),
|
||||
#("p", "prev", "复习上一个"),
|
||||
("d", "toggle_dark", "改变色调"),
|
||||
("v", "play_voice", "朗读"),
|
||||
]
|
||||
@@ -46,6 +46,8 @@ class MemScreen(Screen):
|
||||
self.procession: Procession = self.phaser.current_procession() # type: ignore
|
||||
# logger.debug(self.phaser.state)
|
||||
# self.procession.forward(1)
|
||||
for i in atoms:
|
||||
i.do_eval()
|
||||
|
||||
def on_mount(self):
|
||||
self.load_puzzle()
|
||||
@@ -53,11 +55,10 @@ class MemScreen(Screen):
|
||||
|
||||
def puzzle_widget(self):
|
||||
try:
|
||||
# logger.debug(self.phaser.state)
|
||||
#logger.debug(self.procession.cursor)
|
||||
#logger.debug(self.procession.current_atom)
|
||||
logger.debug(self.phaser.state)
|
||||
logger.debug(self.procession.cursor)
|
||||
logger.debug(self.procession.current_atom)
|
||||
self.fission = Fission(self.procession.current_atom, self.phaser.state)
|
||||
# logger.debug(1)
|
||||
puzzle_debug = next(self.fission.generate())
|
||||
#logger.debug(puzzle_debug)
|
||||
return shim.puzzle2widget[puzzle_debug["puzzle"]](
|
||||
@@ -71,21 +72,33 @@ class MemScreen(Screen):
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header(show_clock=True)
|
||||
with ScrollableContainer():
|
||||
with Center():
|
||||
yield Static(
|
||||
f"当前进度: {self.procession.process()}/{self.procession.total_length()}"
|
||||
)
|
||||
yield Label(self._get_progress_text(), id="progress")
|
||||
|
||||
# self.mount(self.current_widget()) # type: ignore
|
||||
yield ScrollableContainer(id="puzzle-container")
|
||||
# yield Button("重新学习此单元", id="re-recognize", variant="warning")
|
||||
yield Footer()
|
||||
|
||||
def _get_progress_text(self):
|
||||
return f"当前进度: {self.procession.process() + 1}/{self.procession.total_length()}"
|
||||
|
||||
def update_display(self):
|
||||
progress_widget = self.query_one("#progress")
|
||||
progress_widget.update(self._get_progress_text()) # type: ignore
|
||||
|
||||
def load_puzzle(self):
|
||||
container = self.query_one("#puzzle-container")
|
||||
for i in container.children:
|
||||
i.remove()
|
||||
container.mount(self.puzzle_widget())
|
||||
|
||||
def load_finished_widget(self):
|
||||
container = self.query_one("#puzzle-container")
|
||||
for i in container.children:
|
||||
i.remove()
|
||||
from heurams.interface.widgets.finished import Finished
|
||||
container.mount(Finished())
|
||||
|
||||
def on_button_pressed(self, event):
|
||||
event.stop()
|
||||
|
||||
@@ -98,7 +111,13 @@ class MemScreen(Screen):
|
||||
ret = self.procession.forward(1)
|
||||
if ret == 0:
|
||||
self.procession = self.phaser.current_procession() # type: ignore
|
||||
logger.debug(f"建立新队列 {self.procession.phase}")
|
||||
if self.procession == 0:
|
||||
logger.debug(f"记忆进程结束")
|
||||
self.load_finished_widget()
|
||||
return
|
||||
else:
|
||||
logger.debug(f"建立新队列 {self.procession.phase}")
|
||||
self.update_display()
|
||||
self.load_puzzle()
|
||||
|
||||
def action_play_voice(self):
|
||||
|
||||
Reference in New Issue
Block a user