fix: 若干改进
This commit is contained in:
@@ -5,7 +5,7 @@ from textual.widgets import Button
|
||||
from .screens.dashboard import DashboardScreen
|
||||
from .screens.nucreator import NucleonCreatorScreen
|
||||
from .screens.precache import PrecachingScreen
|
||||
|
||||
from .screens.about import AboutScreen
|
||||
class HeurAMSApp(App):
|
||||
TITLE = "潜进"
|
||||
#CSS_PATH = str(cxt.rootdir / "interface" / "css" / "main.css")
|
||||
@@ -15,11 +15,13 @@ class HeurAMSApp(App):
|
||||
("1", "app.push_screen('dashboard')", "仪表盘"),
|
||||
("2", "app.push_screen('precache_all')", "缓存管理器"),
|
||||
("3", "app.push_screen('nucleon_creator')", "创建新单元"),
|
||||
("0", "app.push_screen('about')", "版本信息"),
|
||||
]
|
||||
SCREENS = {
|
||||
"dashboard": DashboardScreen,
|
||||
"nucleon_creator": NucleonCreatorScreen,
|
||||
"precache_all": PrecachingScreen,
|
||||
"about": AboutScreen,
|
||||
}
|
||||
|
||||
def on_mount(self) -> None:
|
||||
@@ -38,6 +40,22 @@ def environment_check():
|
||||
else:
|
||||
print(f"找到 {i}")
|
||||
|
||||
def is_subdir(parent, child):
|
||||
try:
|
||||
child.relative_to(parent)
|
||||
return 1
|
||||
except:
|
||||
return 0
|
||||
|
||||
# 开发模式
|
||||
from pathlib import Path
|
||||
from heurams.context import rootdir
|
||||
import os
|
||||
if is_subdir(Path(rootdir),Path(os.getcwd())):
|
||||
os.chdir(Path(rootdir) / ".." / "..")
|
||||
print(f'转入开发数据目录: {Path(rootdir)/".."/".."}')
|
||||
|
||||
environment_check()
|
||||
|
||||
app = HeurAMSApp()
|
||||
app.run()
|
||||
|
||||
@@ -15,33 +15,27 @@ import heurams.services.version as version
|
||||
from heurams.context import *
|
||||
|
||||
class AboutScreen(Screen):
|
||||
BINDINGS = [
|
||||
("q", "go_back", "返回"),
|
||||
("escape", "quit_app", "退出"),
|
||||
]
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header(show_clock=True)
|
||||
with Container(id="about_container"):
|
||||
yield Label("关于 '潜进' 启发式先进记忆调度器", classes="title-label")
|
||||
yield Static(f"\n版本: {version.ver} {version.codename.capitalize()}")
|
||||
yield Static(f"开发者名单:") # TODO: 取消硬编码, 和 git/vcs 集成
|
||||
yield Static(f"@pluvium27 (Wang Zhiyu)") # TODO: 取消硬编码, 和 git/vcs 集成
|
||||
yield Static(f"Copyright 2025")
|
||||
yield Static("\n")
|
||||
|
||||
yield Label("[b]关于与版本信息[/b]")
|
||||
about_text = f"""
|
||||
## 关于 "潜进"
|
||||
# 关于 "潜进"
|
||||
|
||||
版本 {version.ver} {version.stage}
|
||||
版本 {version.ver} {version.stage.capitalize()}
|
||||
|
||||
开发代号: {version.codename}
|
||||
开发代号: {version.codename.capitalize()}
|
||||
|
||||
一个基于启发式算法的开放源代码记忆调度器, 旨在帮助用户更高效地进行记忆工作与学习规划.
|
||||
|
||||
以 AGPL-3.0 开放源代码
|
||||
|
||||
## 参与贡献
|
||||
贡献人员:
|
||||
|
||||
- @pluvium27 (Wang Zhiyu)
|
||||
|
||||
# 参与贡献
|
||||
|
||||
我们是一个年轻且包容的社区, 由技术人员, 设计师, 文书工作者, 以及创意人员共同构成,
|
||||
|
||||
@@ -87,5 +81,6 @@ class AboutScreen(Screen):
|
||||
self.app.exit()
|
||||
|
||||
def on_button_pressed(self, event) -> None:
|
||||
event.stop()
|
||||
if event.button.id == "back_button":
|
||||
self.action_go_back()
|
||||
self.action_go_back()
|
||||
|
||||
@@ -17,6 +17,7 @@ from heurams.context import *
|
||||
import heurams.services.version as version
|
||||
import heurams.services.timer as timer
|
||||
from .preparation import PreparationScreen
|
||||
from .about import AboutScreen
|
||||
|
||||
import pathlib
|
||||
|
||||
@@ -113,6 +114,10 @@ class DashboardScreen(Screen):
|
||||
from .precache import PrecachingScreen
|
||||
precache_screen = PrecachingScreen()
|
||||
self.app.push_screen(precache_screen)
|
||||
elif event.button.id == "about_button":
|
||||
from .about import AboutScreen
|
||||
about_screen = AboutScreen()
|
||||
self.app.push_screen(about_screen)
|
||||
|
||||
def action_quit_app(self) -> None:
|
||||
self.app.exit()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/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.containers import Center, Container
|
||||
from textual.screen import Screen
|
||||
from textual.reactive import reactive
|
||||
from enum import Enum, auto
|
||||
@@ -34,12 +34,18 @@ class MemScreen(Screen):
|
||||
#print(self.phaser.state)
|
||||
self.procession: Procession = self.phaser.current_procession() # type: ignore
|
||||
#print(self.phaser.state)
|
||||
self.procession.forward(1)
|
||||
self.rating = reactive(0)
|
||||
|
||||
def on_mount(self):
|
||||
self.load_puzzle()
|
||||
pass
|
||||
|
||||
def puzzle_widget(self):
|
||||
try:
|
||||
print(self.phaser.state)
|
||||
self.fission = Fission(self.procession.current_atom, self.phaser.state)
|
||||
#print(1)
|
||||
puzzle_info = next(self.fission.generate())
|
||||
print(puzzle_info)
|
||||
return shim.puzzle2widget[puzzle_info["puzzle"]](atom = self.procession.current_atom, alia = puzzle_info["alia"])
|
||||
@@ -58,8 +64,8 @@ class MemScreen(Screen):
|
||||
yield Footer()
|
||||
|
||||
def load_puzzle(self):
|
||||
container = self.query_one("puzzle-container")
|
||||
for i in puz_container.children:
|
||||
container = self.query_one("#puzzle-container")
|
||||
for i in container.children:
|
||||
i.remove()
|
||||
container.mount(self.puzzle_widget())
|
||||
|
||||
|
||||
@@ -20,6 +20,13 @@ class NucleonCreatorScreen(Screen):
|
||||
def __init__(self) -> None:
|
||||
super().__init__(name=None, id=None, classes=None)
|
||||
|
||||
def search_templates():
|
||||
from heurams.context import
|
||||
|
||||
def search_templates(self):
|
||||
with open('r','/template/t.timl'):
|
||||
pass
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header(show_clock=True)
|
||||
with Container(id="vice_container"):
|
||||
@@ -30,10 +37,11 @@ class NucleonCreatorScreen(Screen):
|
||||
yield Markdown("> 单元集名称不应与现有单元集重复. \n> 新的单元集文件将创建在 ./nucleon/你输入的名称.toml")
|
||||
yield Label(f"\n")
|
||||
yield Markdown("2. 选择单元集模板")
|
||||
LINES = f"""带有宏支持的空白单元集 ({ver})
|
||||
LINES = self.search_templates()
|
||||
"""带有宏支持的空白单元集 ({ver})
|
||||
古诗词模板单元集 ({ver})
|
||||
英语词汇和短语模板单元集 ({ver})
|
||||
""".splitlines()
|
||||
"""
|
||||
yield Select.from_values(LINES, prompt="选择类型")
|
||||
yield Markdown("> 新单元集的版本号将和主程序版本保持同步")
|
||||
yield Label(f"\n")
|
||||
@@ -58,4 +66,6 @@ class NucleonCreatorScreen(Screen):
|
||||
self.app.exit()
|
||||
|
||||
def on_button_pressed(self, event) -> None:
|
||||
pass
|
||||
event.stop()
|
||||
if event.button.id == 'submit_button':
|
||||
pass
|
||||
|
||||
@@ -33,12 +33,12 @@ class Procession():
|
||||
|
||||
def __len__(self):
|
||||
return (len(self.queue) - self.cursor)
|
||||
|
||||
|
||||
def process(self):
|
||||
return (self.cursor)
|
||||
|
||||
|
||||
def total_length(self):
|
||||
return len(self.queue)
|
||||
|
||||
def is_empty(self):
|
||||
return len(self.queue)
|
||||
return len(self.queue)
|
||||
|
||||
Reference in New Issue
Block a user