代码之家  ›  专栏  ›  技术社区  ›  javispado

更改python丰富面板中的标题颜色

  •  0
  • javispado  · 技术社区  · 2 年前

    是否可以更改python富面板中的标题颜色? 我试过几种方法,但都没有成功。

    这是我的代码:

    from rich.console import Console
    from rich.markdown import Markdown
    from rich.panel import Panel
    import configuracion
    from rich import print
    
    def imprime_comandos (comandos: list, consola: Console, ancho_panel: int) -> None:
        formato_comandos = '\n\n'.join([f""" `{c}`""" for c in comandos])
    
        salida_cmd = Markdown(
            formato_comandos,
            inline_code_lexer = 'bash',
        )
    
        consola.print (
            Panel(
                salida_cmd,
                title = "[red]Comando/s[/red]",
                title_align = 'left',
                width = ancho_panel,
            )
        )
    def imprime_extras (extras: list, consola: Console, ancho_panel: int) -> None:
        formato_extra = '\n'.join([f"""* {ex}""" for ex in extras])
    
        salida_extras = Markdown(formato_extra)
        salida_extras_str = str(salida_extras)
        salida_extras_str = re.sub(r"|", "", salida_extras_str)
    
        consola.print (
            Panel(
                salida_extras,
                title = '[red]Ten en cuenta...[/red]',
                title_align = 'left',
                width = ancho_panel,
            )
        )
    

    我希望把标题印成红色

    0 回复  |  直到 2 年前