72 lines
2.3 KiB
Python
72 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
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 enum import Enum, auto
|
|
|
|
from heurams.context import config_var
|
|
from heurams.kernel.reactor import *
|
|
import heurams.kernel.particles as pt
|
|
import heurams.kernel.puzzles as pz
|
|
from .. import shim
|
|
|
|
class AtomState(Enum):
|
|
FAILED = auto()
|
|
NORMAL = auto()
|
|
|
|
class MemScreen(Screen):
|
|
BINDINGS = [
|
|
("q", "pop_screen", "返回"),
|
|
("p", "pop_screen", "上一个"),
|
|
("d", "toggle_dark", "改变色调"),
|
|
("v", "play_voice", "朗读"),
|
|
]
|
|
|
|
if config_var.get()["quick_pass"]:
|
|
BINDINGS.append(("k", "quick_pass", "跳过"))
|
|
|
|
def __init__(self, atoms: list, name: str | None = None, id: str | None = None, classes: str | None = None) -> None:
|
|
super().__init__(name, id, classes)
|
|
self.atoms = atoms
|
|
#print(atoms)
|
|
self.phaser = Phaser(atoms)
|
|
self.procession: Procession = self.phaser.current_procession() # type: ignore
|
|
|
|
def current_widget(self):
|
|
self.fission = Fission(self.procession.current_atom, self.phaser.state)
|
|
puzzle_info = next(self.fission.generate())
|
|
print(puzzle_info)
|
|
return shim.puzzle2widget[puzzle_info["puzzle"]](atom = self.procession.current_atom, alia = puzzle_info["alia"])
|
|
#print(shim.puzzle2widget[puzzle_info["puzzle"]])
|
|
|
|
def compose(self) -> ComposeResult:
|
|
yield Header(show_clock=True)
|
|
with Center():
|
|
yield Static(f"当前进度: {self.procession.process()}/{self.procession.total_length()}")
|
|
#self.mount(self.current_widget()) # type: ignore
|
|
yield Button("重新学习此单元", id="re-recognize", variant="warning")
|
|
yield Footer()
|
|
|
|
def on_mount(self):
|
|
pass
|
|
|
|
def on_button_pressed(self, event):
|
|
pass
|
|
|
|
def action_play_voice(self):
|
|
"""朗读当前内容"""
|
|
pass
|
|
|
|
def action_precache_current(self):
|
|
"""预缓存当前单元集的音频"""
|
|
#from .precache import PrecachingScreen
|
|
#precache_screen = PrecachingScreen(self.nucleon_file)
|
|
#self.app.push_screen(precache_screen)
|
|
|
|
def action_toggle_dark(self):
|
|
self.app.action_toggle_dark()
|
|
|
|
def action_pop_screen(self):
|
|
self.app.pop_screen()
|