IngoMeyer441 / simple-term-menu

A Python package which creates simple interactive menus on the command line.
MIT License
492 stars 43 forks source link

colors to the title #75

Open ali-0x11 opened 1 year ago

ali-0x11 commented 1 year ago

How I can add colors to the title ?

IngoMeyer441 commented 1 year ago

Unfortunately, this is not really possible at the moment. You could directly inject terminal escape codes into the title string, like this:

#!/usr/bin/env python3

from simple_term_menu import TerminalMenu

def main():
    terminal_menu = TerminalMenu(["Apple", "Banana", "Peach"], title="\33[32mFruits\33[m")
    terminal_menu.show()
    print(f"Your choice: {terminal_menu.chosen_menu_entry}")

if __name__ == "__main__":
    main()

But this breaks the title line length calculation routine and leads to a broken menu display on repaint. This is related to issue #14 and hopefully can be fixed soon.