#!/usr/bin/env python3 from textual.app import ComposeResult from textual.widgets import ( Header, Footer, Label, Input, Select, Button, Markdown, ) from textual.containers import Container from textual.screen import Screen class NucleonCreatorScreen(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"[b]新建空的单元集\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) -> None: pass