新建单元集界面改进
This commit is contained in:
49
screens.py
49
screens.py
@@ -2,6 +2,7 @@ from textual.app import App, ComposeResult
|
||||
from textual.widgets import (
|
||||
Header,
|
||||
Footer,
|
||||
Input,
|
||||
ListView,
|
||||
ProgressBar,
|
||||
DirectoryTree,
|
||||
@@ -10,6 +11,7 @@ from textual.widgets import (
|
||||
Markdown,
|
||||
Static,
|
||||
Button,
|
||||
Select,
|
||||
)
|
||||
from textual.containers import Container, Horizontal, Center
|
||||
from textual.screen import Screen
|
||||
@@ -140,7 +142,6 @@ class MemScreen(Screen):
|
||||
def action_pop_screen(self):
|
||||
self.app.pop_screen()
|
||||
|
||||
|
||||
class PreparationScreen(Screen):
|
||||
BINDINGS = [("q", "go_back", "返回"), ("escape", "quit_app", "退出")]
|
||||
|
||||
@@ -187,6 +188,48 @@ class PreparationScreen(Screen):
|
||||
)
|
||||
self.app.push_screen(newscr)
|
||||
|
||||
class NewNucleonScreen(Screen):
|
||||
BINDINGS = [("q", "go_back", "返回"), ("escape", "quit_app", "退出")]
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__(name=None, id=None, classes=None)
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header(show_clock=True)
|
||||
with Container(id="vice_container"):
|
||||
yield Label(f"新建空的单元集\n")
|
||||
yield Markdown("1. 键入单元集名称")
|
||||
yield Input(placeholder="单元集名称")
|
||||
yield Markdown("> 单元集名称不应与现有单元集重复, 新的单元集文件将创建在 ./nucleon/你输入的名称.toml")
|
||||
yield Label(f"\n")
|
||||
yield Markdown("2. 选择单元集类型")
|
||||
LINES = """
|
||||
单一字符串
|
||||
主字符串(带有附加属性)
|
||||
动态单元集(使用宏)
|
||||
""".splitlines()
|
||||
yield Select.from_values(LINES, prompt="选择类型")
|
||||
yield Label(f"\n")
|
||||
yield Markdown("3. 输入附加元数据 (可选)")
|
||||
yield Input(placeholder="作者")
|
||||
yield Input(placeholder="内容描述")
|
||||
yield Button(
|
||||
"新建空单元集",
|
||||
id="submit_button",
|
||||
variant="primary",
|
||||
classes="start-button",
|
||||
)
|
||||
yield Footer()
|
||||
|
||||
def action_go_back(self):
|
||||
self.app.pop_screen()
|
||||
|
||||
def action_quit_app(self):
|
||||
self.app.exit()
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||
pass
|
||||
|
||||
class DashboardScreen(Screen):
|
||||
def compose(self) -> ComposeResult:
|
||||
yield Header(show_clock=True)
|
||||
@@ -259,9 +302,7 @@ class DashboardScreen(Screen):
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||
if event.button.id == "new_nucleon_button":
|
||||
newscr = MemScreen(
|
||||
self.nucleon_file, self.electron_file, config.get("tasked_number", 6)
|
||||
)
|
||||
newscr = NewNucleonScreen()
|
||||
self.app.push_screen(newscr)
|
||||
|
||||
def action_quit_app(self) -> None:
|
||||
|
Reference in New Issue
Block a user