Closed Tbruno25 closed 2 years ago
Good day!
This is a known issue with the line-breaker algorithm, AFAIK it currently completely ignores \n
characters. This will be fixed sometime post-1.0.0, until then you can add content line-by-line to a widget for a band-aid fix.
All I'm doing here is unpacking a generator that goes through the plot split by linebreaks. Any unnamed argument to Container
is considered a potential Widget
, so the auto()
method is run on it to convert it as such. A more verbose way would be this:
# `plot` is already defined above
import pytermgui as ptg
root = ptg.Container()
for line in plot.splitlines():
root += ptg.Label(line)
root.print()
Thank you for your interest, I hope this module will be useful for you. If you create any public projects with it, you can always contact me for a shoutout in the README
.
Thank you for the temporary solution!
I spent an hour experimenting and think I'm going to hold off until the api / library is a bit more mature. I look forward to revisiting this in the near future!
Hey @Tbruno25! I know it's been like 8 months, but there is now a break_line
implementation that works with newlines, and should work for your usecase!
I'm looking to create multiple plot trend lines inside of a tui.
Another library I'm utilizing produces a string such as
'⠀⠀⠀⠀⢠⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⡆⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀\n⠀⠀⠀⠀⡸⡇⠀⠀⠀⠀⠀⠀⠀⠀⢠⢳⠀⠀⠀⠀⠀⣧⠀⠀⡤⡄⠀⠀⠀⠀\n⠀⠀⠀⢀⠇⡇⠀⠀⠀⠀⠀⠀⠀⠀⢸⠘⡄⠀⠀⡀⢠⢻⠀⢀⠇⡇⠀⢀⠀⠀\n⡆⠀⢀⠎⠀⢣⠀⠀⠀⠀⠀⠀⠀⠀⡜⠀⡇⠀⠀⡇⢸⢸⠀⢸⠀⢇⠀⢸⠀⠀\n⢣⠀⡸⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⢇⠀⢰⢇⢸⠈⡆⢸⠀⢸⠀⡿⡀⠀\n⢸⠀⡇⠀⠀⢸⠀⢀⠤⡆⠀⠀⠀⢸⠀⠀⢸⠀⢸⢸⢸⠀⡇⡎⠀⢸⠀⡇⡇⠀\n⠘⣼⠀⠀⠀⢸⠀⢸⠀⢱⠀⠀⠀⡎⠀⠀⢸⠀⢸⢸⢸⠀⡇⡇⠀⢸⢠⠃⡇⢀\n⠀⠇⠀⠀⠀⢸⠀⡎⠀⠘⡄⠀⢸⠀⠀⠀⠘⡄⡜⢸⢸⠀⢣⠇⠀⢸⢸⠀⡇⢸\n⠀⠀⠀⠀⠀⢸⠀⡇⠀⠀⡇⠀⡇⠀⠀⠀⠀⡇⡇⠸⡇⠀⢸⠀⠀⠀⣿⠀⢣⢸\n⠀⠀⠀⠀⠀⢸⠀⡇⠀⠀⢸⢰⠁⠀⠀⠀⠀⡇⡇⠀⡇⠀⠀⠀⠀⠀⡇⠀⢸⢸\n⠀⠀⠀⠀⠀⠸⣰⠁⠀⠀⠀⠇⠀⠀⠀⠀⠀⢳⠁⠀⠇⠀⠀⠀⠀⠀⠁⠀⢸⢸\n⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡸\n⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡇\n⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇\n⠀⠀⠀⠀⠀⠀⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠃'
When printed from the python interpreter this formats correctly
⠀⠀⠀⠀⢠⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⡆⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⡸⡇⠀⠀⠀⠀⠀⠀⠀⠀⢠⢳⠀⠀⠀⠀⠀⣧⠀⠀⡤⡄⠀⠀⠀⠀ ⠀⠀⠀⢀⠇⡇⠀⠀⠀⠀⠀⠀⠀⠀⢸⠘⡄⠀⠀⡀⢠⢻⠀⢀⠇⡇⠀⢀⠀⠀ ⡆⠀⢀⠎⠀⢣⠀⠀⠀⠀⠀⠀⠀⠀⡜⠀⡇⠀⠀⡇⢸⢸⠀⢸⠀⢇⠀⢸⠀⠀ ⢣⠀⡸⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⢇⠀⢰⢇⢸⠈⡆⢸⠀⢸⠀⡿⡀⠀ ⢸⠀⡇⠀⠀⢸⠀⢀⠤⡆⠀⠀⠀⢸⠀⠀⢸⠀⢸⢸⢸⠀⡇⡎⠀⢸⠀⡇⡇⠀ ⠘⣼⠀⠀⠀⢸⠀⢸⠀⢱⠀⠀⠀⡎⠀⠀⢸⠀⢸⢸⢸⠀⡇⡇⠀⢸⢠⠃⡇⢀ ⠀⠇⠀⠀⠀⢸⠀⡎⠀⠘⡄⠀⢸⠀⠀⠀⠘⡄⡜⢸⢸⠀⢣⠇⠀⢸⢸⠀⡇⢸ ⠀⠀⠀⠀⠀⢸⠀⡇⠀⠀⡇⠀⡇⠀⠀⠀⠀⡇⡇⠸⡇⠀⢸⠀⠀⠀⣿⠀⢣⢸ ⠀⠀⠀⠀⠀⢸⠀⡇⠀⠀⢸⢰⠁⠀⠀⠀⠀⡇⡇⠀⡇⠀⠀⠀⠀⠀⡇⠀⢸⢸ ⠀⠀⠀⠀⠀⠸⣰⠁⠀⠀⠀⠇⠀⠀⠀⠀⠀⢳⠁⠀⠇⠀⠀⠀⠀⠀⠁⠀⢸⢸ ⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡸ ⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡇ ⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇ ⠀⠀⠀⠀⠀⠀⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠃
However, when added to a pytermgui widget it does not render correctly.
Is there any easy way to overcome this?
Also -- thank you for sharing your library, it really is awesome.