0

Formating in python

I tried to add the code here it simply can’t get complied since it neeeds to bee run from terminal py pycharm visual studio ,i can add it anyways as a file if it is needed later on But basically i made a board And used reset=“\033[0m” BLUE=“\033[7;34m” Empty=f’{BLUE}*{reset}’ So that for an empty element in a list i get color blue for background , Default black for text And reset at the end The board was printed nicely and all Yet i could not make the cells more thick to get somewhat comfy design

14th Jan 2025, 4:35 PM
Dareen Moughrabi
Dareen Moughrabi - avatar
7 RĂ©ponses
+ 2
cli apps use fonts and special characters. You are limited by what is supported by the specific terminal you are running it on. What fonts are available is also something to consider when designing the look of your interface. What works on your setup might not work elsewhere if the font, os and terminal is different. some useful libraries: termcolor https://pypi.org/project/termcolor/ colorama https://pypi.org/project/colorama/ blessings https://pypi.org/project/blessings/ rich https://pypi.org/project/rich/ for tables maybe use this: prettytable https://pypi.org/project/prettytable/ tabulate https://pypi.org/project/tabulate/
15th Jan 2025, 12:51 AM
Bob_Li
Bob_Li - avatar
+ 1
you can also use pandas to print tables in the terminal, but you also need to pip install tabulate https://sololearn.com/compiler-playground/cblsOrK8ELIF/?ref=app
15th Jan 2025, 5:48 AM
Bob_Li
Bob_Li - avatar
+ 1
Bob_Li i only knew that i can minupulate the command line interface on my part on the custmization level , i assumed whatever terminal had the default settings maybe with additional featuers , for fonts i kind of noticed that some terminals default to white text on black background , some to gray background , some to other text colors and background But other than that i am under educated , I will leave this for a bit in order to maybe see additional intersting answers and read about the libraries you provied , thank you for your time and the resources you provied , very helpful as always🙏 , will be surec to accept an answer soon
15th Jan 2025, 7:13 AM
Dareen Moughrabi
Dareen Moughrabi - avatar
+ 1
ansi colors: copy paste the content as a python file so you have a reference for the ansi codes and what they look like when displayed. https://gist.githubusercontent.com/rene-d/9e584a7dd2935d0f461904b9f2950007/raw/e2e58ccf955475d8066338a4e538c52debc06a06/colors.py maybe for bold you need BOLD = "\033[1m"
15th Jan 2025, 7:41 AM
Bob_Li
Bob_Li - avatar
+ 1
just remember that not all ansii codes might be supported by your terminal.
15th Jan 2025, 8:18 AM
Bob_Li
Bob_Li - avatar
0
you can use functions and classes to build your ansii codes https://sololearn.com/compiler-playground/chN6NkY252uW/?ref=app
15th Jan 2025, 8:14 AM
Bob_Li
Bob_Li - avatar
0
🙌🙏thank you this is a really gem mine
15th Jan 2025, 8:24 AM
Dareen Moughrabi
Dareen Moughrabi - avatar