fix: 改进
This commit is contained in:
@@ -26,7 +26,7 @@ class MemScreen(Screen):
|
|||||||
|
|
||||||
if config_var.get()["quick_pass"]:
|
if config_var.get()["quick_pass"]:
|
||||||
BINDINGS.append(("k", "quick_pass", "跳过"))
|
BINDINGS.append(("k", "quick_pass", "跳过"))
|
||||||
|
rating = reactive(-1)
|
||||||
def __init__(self, atoms: list, name: str | None = None, id: str | None = None, classes: str | None = None) -> None:
|
def __init__(self, atoms: list, name: str | None = None, id: str | None = None, classes: str | None = None) -> None:
|
||||||
super().__init__(name, id, classes)
|
super().__init__(name, id, classes)
|
||||||
self.atoms = atoms
|
self.atoms = atoms
|
||||||
@@ -34,8 +34,8 @@ class MemScreen(Screen):
|
|||||||
#print(self.phaser.state)
|
#print(self.phaser.state)
|
||||||
self.procession: Procession = self.phaser.current_procession() # type: ignore
|
self.procession: Procession = self.phaser.current_procession() # type: ignore
|
||||||
#print(self.phaser.state)
|
#print(self.phaser.state)
|
||||||
self.procession.forward(1)
|
#self.procession.forward(1)
|
||||||
self.rating = reactive(0)
|
|
||||||
|
|
||||||
def on_mount(self):
|
def on_mount(self):
|
||||||
self.load_puzzle()
|
self.load_puzzle()
|
||||||
@@ -60,7 +60,7 @@ class MemScreen(Screen):
|
|||||||
yield Static(f"当前进度: {self.procession.process()}/{self.procession.total_length()}")
|
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 Container(id="puzzle-container")
|
||||||
yield Button("重新学习此单元", id="re-recognize", variant="warning")
|
#yield Button("重新学习此单元", id="re-recognize", variant="warning")
|
||||||
yield Footer()
|
yield Footer()
|
||||||
|
|
||||||
def load_puzzle(self):
|
def load_puzzle(self):
|
||||||
@@ -72,8 +72,11 @@ class MemScreen(Screen):
|
|||||||
def on_button_pressed(self, event):
|
def on_button_pressed(self, event):
|
||||||
event.stop()
|
event.stop()
|
||||||
|
|
||||||
def watch_rating(self, old_value, new_value) -> None:
|
def watch_rating(self, old_rating, new_rating) -> None:
|
||||||
forwards = 1 if new_value >= 4 else 0
|
if new_rating == -1:
|
||||||
|
return
|
||||||
|
forwards = 1 if new_rating >= 4 else 0
|
||||||
|
self.rating = -1
|
||||||
if forwards:
|
if forwards:
|
||||||
self.procession.forward(1)
|
self.procession.forward(1)
|
||||||
self.load_puzzle()
|
self.load_puzzle()
|
||||||
|
|||||||
@@ -28,12 +28,6 @@ class Recognition(BasePuzzleWidget):
|
|||||||
alia = "Recognition"
|
alia = "Recognition"
|
||||||
self.alia = alia
|
self.alia = alia
|
||||||
|
|
||||||
class RatingChanged(Message):
|
|
||||||
"""评分改变消息"""
|
|
||||||
def __init__(self, rating: int) -> None:
|
|
||||||
self.rating = rating
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
def compose(self):
|
def compose(self):
|
||||||
cfg: RecognitionConfig = self.atom.registry["orbital"]["puzzles"][self.alia]
|
cfg: RecognitionConfig = self.atom.registry["orbital"]["puzzles"][self.alia]
|
||||||
delim = self.atom.registry['nucleon'].metadata["formation"]["delimiter"]
|
delim = self.atom.registry['nucleon'].metadata["formation"]["delimiter"]
|
||||||
@@ -85,4 +79,4 @@ class Recognition(BasePuzzleWidget):
|
|||||||
|
|
||||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||||
if event.button.id == "ok":
|
if event.button.id == "ok":
|
||||||
self.post_message(self.RatingChanged(5))
|
self.screen.rating = 5 # type: ignore
|
||||||
Reference in New Issue
Block a user