I have a class to print "TextBoxes" that look similar to
#========================================#
| |
| |
| |
| |
| |
#========================================#
When given dimensions. You can then assign lines text by calling the method setLineText. Each line is stored in a list and printed with the method render with a simple for loop.
Everything works fine and dandy until I introduce Colorama to the mix, when I use my setLineText method with any Colorama formatting the line that I changed will always be short 5 spaces per call I used for formatting
For example,
MainBox = views.TextBox(35, 6)
MainBox.setLineText(1, "Hello! " + Fore.RED + User.name + Fore.RESET)
MainBox.Render()
will output
#=================================#
| Hello! User |
| |
| |
| |
#=================================#
My question is, is there a way to avoid prevent this from happening?
EDIT: As an extra note, I'm using windows.
ANSWER: After tons of testing, any regex I could come up with didn't work. My solution is to just use sys.stdout.write() to print the color changes and resets. It works well and hardly even need to change my current code