fix: 改进

This commit is contained in:
2025-12-11 12:36:00 +08:00
parent a8ae1bacf3
commit 05a885a9d2
5 changed files with 32 additions and 9 deletions

View File

@@ -3,6 +3,7 @@ from textual.app import ComposeResult
from textual.widgets import Header, Footer, Label, Static, Button
from textual.containers import Center
from textual.screen import Screen
from textual.reactive import reactive
from enum import Enum, auto
from heurams.context import config_var
@@ -33,8 +34,10 @@ class MemScreen(Screen):
#print(self.phaser.state)
self.procession: Procession = self.phaser.current_procession() # type: ignore
#print(self.phaser.state)
self.rating = reactive(0)
def current_widget(self):
def puzzle_widget(self):
try:
self.fission = Fission(self.procession.current_atom, self.phaser.state)
puzzle_info = next(self.fission.generate())
@@ -49,16 +52,25 @@ class MemScreen(Screen):
yield Header(show_clock=True)
with Center():
yield Static(f"当前进度: {self.procession.process()}/{self.procession.total_length()}")
self.mount(self.current_widget()) # type: ignore
#self.mount(self.current_widget()) # type: ignore
yield Container(id="puzzle-container")
yield Button("重新学习此单元", id="re-recognize", variant="warning")
yield Footer()
def on_mount(self):
pass
def load_puzzle(self):
container = self.query_one("puzzle-container")
for i in puz_container.children:
i.remove()
container.mount(self.puzzle_widget())
def on_button_pressed(self, event):
event.stop()
if
def watch_rating(self, old_value, new_value) -> None:
forwards = 1 if new_value >= 4 else 0
if forwards:
self.procession.forward(1)
self.load_puzzle()
def action_play_voice(self):
"""朗读当前内容"""