fix: 完善
This commit is contained in:
@@ -105,7 +105,7 @@ class DashboardScreen(Screen):
|
||||
def on_button_pressed(self, event) -> None:
|
||||
if event.button.id == "new_nucleon_button":
|
||||
# 切换到创建单元
|
||||
from .nucleon_creator import NucleonCreatorScreen
|
||||
from .nucreator import NucleonCreatorScreen
|
||||
newscr = NucleonCreatorScreen()
|
||||
self.app.push_screen(newscr)
|
||||
elif event.button.id == "precache_all_button":
|
||||
|
||||
@@ -18,7 +18,7 @@ class AtomState(Enum):
|
||||
class MemScreen(Screen):
|
||||
BINDINGS = [
|
||||
("q", "pop_screen", "返回"),
|
||||
#("p", "prev", "上一个"),
|
||||
("p", "prev", "复习上一个"),
|
||||
("d", "toggle_dark", "改变色调"),
|
||||
("v", "play_voice", "朗读"),
|
||||
]
|
||||
@@ -58,6 +58,7 @@ class MemScreen(Screen):
|
||||
|
||||
def on_button_pressed(self, event):
|
||||
event.stop()
|
||||
if
|
||||
|
||||
def action_play_voice(self):
|
||||
"""朗读当前内容"""
|
||||
|
||||
@@ -12,8 +12,10 @@ from textual.widgets import (
|
||||
from textual.containers import Container
|
||||
from textual.screen import Screen
|
||||
|
||||
from heurams.services.version import ver
|
||||
|
||||
class NucleonCreatorScreen(Screen):
|
||||
BINDINGS = [("q", "go_back", "返回"), ("escape", "quit_app", "退出")]
|
||||
BINDINGS = [("q", "go_back", "返回")]
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__(name=None, id=None, classes=None)
|
||||
@@ -21,30 +23,34 @@ class NucleonCreatorScreen(Screen):
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header(show_clock=True)
|
||||
with Container(id="vice_container"):
|
||||
yield Label(f"[b]新建空的单元集\n")
|
||||
yield Label(f"[b]空白单元集创建向导\n")
|
||||
yield Markdown("> 提示: 你可能注意到当选中文本框时底栏和操作按键绑定将被覆盖 \n只需选中(使用鼠标或 Tab)选择框即可恢复底栏功能")
|
||||
yield Markdown("1. 键入单元集名称")
|
||||
yield Input(placeholder="单元集名称")
|
||||
yield Markdown("> 单元集名称不应与现有单元集重复, 新的单元集文件将创建在 ./nucleon/你输入的名称.toml")
|
||||
yield Markdown("> 单元集名称不应与现有单元集重复. \n> 新的单元集文件将创建在 ./nucleon/你输入的名称.toml")
|
||||
yield Label(f"\n")
|
||||
yield Markdown("2. 选择单元集类型")
|
||||
LINES = """
|
||||
单一字符串
|
||||
主字符串(带有附加属性)
|
||||
动态单元集(使用宏)
|
||||
yield Markdown("2. 选择单元集模板")
|
||||
LINES = f"""带有宏支持的空白单元集 ({ver})
|
||||
古诗词模板单元集 ({ver})
|
||||
英语词汇和短语模板单元集 ({ver})
|
||||
""".splitlines()
|
||||
yield Select.from_values(LINES, prompt="选择类型")
|
||||
yield Markdown("> 新单元集的版本号将和主程序版本保持同步")
|
||||
yield Label(f"\n")
|
||||
yield Markdown("3. 输入附加元数据 (可选)")
|
||||
yield Markdown("3. 输入常见附加元数据 (可选)")
|
||||
yield Input(placeholder="作者")
|
||||
yield Input(placeholder="内容描述")
|
||||
yield Button(
|
||||
"新建空单元集",
|
||||
"新建空白单元集",
|
||||
id="submit_button",
|
||||
variant="primary",
|
||||
classes="start-button",
|
||||
)
|
||||
yield Footer()
|
||||
|
||||
def on_mount(self):
|
||||
self.query_one("#submit_button").focus()
|
||||
|
||||
def action_go_back(self):
|
||||
self.app.pop_screen()
|
||||
|
||||
@@ -177,26 +177,16 @@ class PrecachingScreen(Screen):
|
||||
nu = list()
|
||||
for file in nucleon_files:
|
||||
try:
|
||||
nu += pt.load_nucleon(file)[0]
|
||||
self.total = len(nu)
|
||||
for i in pt.load_nucleon(file):
|
||||
nu.append(i[0])
|
||||
except:
|
||||
continue
|
||||
|
||||
self.processed = 0
|
||||
self.is_precaching = True
|
||||
|
||||
for file in nucleon_files:
|
||||
try:
|
||||
nu += pt.load_nucleon(file)[0]
|
||||
if not self.precache_by_list(nu):
|
||||
break # 用户取消
|
||||
except Exception as e:
|
||||
print(f"处理文件失败 {file}: {e}")
|
||||
continue
|
||||
|
||||
self.is_precaching = False
|
||||
self.update_status("完成", "所有单元的音频已被预缓存", 100)
|
||||
|
||||
self.total = len(nu)
|
||||
for i in nu:
|
||||
i: pt.Nucleon
|
||||
i.do_eval()
|
||||
return self.precache_by_list(nu)
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||
event.stop()
|
||||
if event.button.id == "start_precache" and not self.is_precaching:
|
||||
|
||||
Reference in New Issue
Block a user