新建单元集界面改进
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 (
|
from textual.widgets import (
|
||||||
Header,
|
Header,
|
||||||
Footer,
|
Footer,
|
||||||
|
Input,
|
||||||
ListView,
|
ListView,
|
||||||
ProgressBar,
|
ProgressBar,
|
||||||
DirectoryTree,
|
DirectoryTree,
|
||||||
@@ -10,6 +11,7 @@ from textual.widgets import (
|
|||||||
Markdown,
|
Markdown,
|
||||||
Static,
|
Static,
|
||||||
Button,
|
Button,
|
||||||
|
Select,
|
||||||
)
|
)
|
||||||
from textual.containers import Container, Horizontal, Center
|
from textual.containers import Container, Horizontal, Center
|
||||||
from textual.screen import Screen
|
from textual.screen import Screen
|
||||||
@@ -140,7 +142,6 @@ class MemScreen(Screen):
|
|||||||
def action_pop_screen(self):
|
def action_pop_screen(self):
|
||||||
self.app.pop_screen()
|
self.app.pop_screen()
|
||||||
|
|
||||||
|
|
||||||
class PreparationScreen(Screen):
|
class PreparationScreen(Screen):
|
||||||
BINDINGS = [("q", "go_back", "返回"), ("escape", "quit_app", "退出")]
|
BINDINGS = [("q", "go_back", "返回"), ("escape", "quit_app", "退出")]
|
||||||
|
|
||||||
@@ -187,6 +188,48 @@ class PreparationScreen(Screen):
|
|||||||
)
|
)
|
||||||
self.app.push_screen(newscr)
|
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):
|
class DashboardScreen(Screen):
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Header(show_clock=True)
|
yield Header(show_clock=True)
|
||||||
@@ -259,9 +302,7 @@ class DashboardScreen(Screen):
|
|||||||
|
|
||||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||||
if event.button.id == "new_nucleon_button":
|
if event.button.id == "new_nucleon_button":
|
||||||
newscr = MemScreen(
|
newscr = NewNucleonScreen()
|
||||||
self.nucleon_file, self.electron_file, config.get("tasked_number", 6)
|
|
||||||
)
|
|
||||||
self.app.push_screen(newscr)
|
self.app.push_screen(newscr)
|
||||||
|
|
||||||
def action_quit_app(self) -> None:
|
def action_quit_app(self) -> None:
|
||||||
|
Reference in New Issue
Block a user