【AI】创建 claude code cli 风格的欢迎界面
使用 “Test All” 功能,找到最接近你想要的那种块状风格,复制下来,作为一个多行字符串(Triple-quoted string)放进 Python 代码中,然后用 Rich 赋予它 #d07354 颜色。尝试使用 Sub-Zero、ANSI Shadow、Cyberlarge 或 Blocks 字体,claude code cli欢迎界面使用的就是ANSI Shadow字体。你可以去一些
·
使用高级 ANSI 字体生成器(Text to ANSI)
不要局限于 Python 自带的 pyfiglet 字体。你可以去一些专业的 ANSI Art 网站生成文本,然后直接把生成的字符串复制到代码里。
去 TAAG (Text to ASCII Art Generator)。
尝试使用 Sub-Zero、ANSI Shadow、Cyberlarge 或 Blocks 字体,claude code cli欢迎界面使用的就是ANSI Shadow字体。
使用 “Test All” 功能,找到最接近你想要的那种块状风格,复制下来,作为一个多行字符串(Triple-quoted string)放进 Python 代码中,然后用 Rich 赋予它 #d07354 颜色。
import sys
from rich.console import Console
from rich.panel import Panel
from rich.text import Text
from rich.align import Align
# ==========================================
# 1. 替换为你的 ASCII Art (注意保留前面的 'r')
# ==========================================
MY_AGENT_LOGO = r"""
█████╗ ██████╗ ███████╗███╗ ██╗████████╗
██╔══██╗██╔════╝ ██╔════╝████╗ ██║╚══██╔══╝
███████║██║ ███╗█████╗ ██╔██╗ ██║ ██║
██╔══██║██║ ██║██╔══╝ ██║╚██╗██║ ██║
██║ ██║╚██████╔╝███████╗██║ ╚████║ ██║
╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝
"""
def show_welcome_screen():
# 初始化 Rich 控制台
console = Console()
# 清空屏幕,让欢迎界面更干净
console.clear()
# ==========================================
# 2. 顶部欢迎横幅 (Claude Code 风格)
# ==========================================
welcome_text = Text()
welcome_text.append("* Welcome to the ", style="dim white")
# 你可以在这里修改你的 Agent 名字
welcome_text.append("My Agent", style="bold white")
welcome_text.append(" research preview!", style="dim white")
banner = Panel(
welcome_text,
border_style="#d07354", # Claude 风格的赤陶色/黏土橙
expand=False,
padding=(0, 1)
)
console.print("\n")
console.print(Align.center(banner))
console.print("\n")
# ==========================================
# 3. 打印核心 Logo
# ==========================================
# 将你粘贴的 ASCII Art 赋予相同的颜色并加粗
colored_logo = Text(MY_AGENT_LOGO, style="bold #d07354")
console.print(Align.center(colored_logo))
console.print("\n")
# ==========================================
# 4. 底部登录/继续提示
# ==========================================
footer = Text()
footer.append("🎉 Login successful. Press ", style="dim cyan")
footer.append("Enter", style="bold cyan")
footer.append(" to continue", style="dim cyan")
console.print(Align.center(footer))
console.print("\n")
# ==========================================
# 5. 暂停等待用户回车
# ==========================================
try:
input()
except KeyboardInterrupt:
# 优雅处理用户按 Ctrl+C 退出的情况
console.print("\n[dim]Exiting...[/dim]")
sys.exit(0)
if __name__ == "__main__":
# 测试运行
show_welcome_screen()
更多推荐



所有评论(0)