I have created a table using Table in manim, and i want to simply read the value in one of the cells.
As an example imagine i have written "a" in row 0 column 0, i want to say:
If mytable.get_rows()[0][0] == "a":
mytable.get_rows()[0][0].set_color(RED)
you see, its not necessarily changing the color that i want, that was just an example. I want to be able to read a table cell to compare it, when i try to print it, it prints vmobjectsvgpath, i tried many different things like str method to convert it to string or using get_ entries()
, but none of them works, this is a problem that is seen in Text as well.
I asked AI but didnt get a good answer, answers were more like try get_tex_string()
or .text()
,... where either do not exist or do not work.
I explained above that i tried many different methods, but none of them work.
dir()
is your friend.
Use it to learn the set of attributes you can ask for help()
about.
>>> from pprint import pp
>>> from manim import Table, Text
>>>
>>> t0 = Table(
... [["This", "is a"],
... ["simple", "Table in \n Manim."]])
>>>
>>> t0.get_rows()[0][1]
Paragraph(VGroup of 3 submobjects)
>>>
>>> t0.get_rows()[0][1].color
ManimColor('#FFFFFF')
>>>
>>> t0.get_rows()[0][1].lines_text
Text('is a')
>>>
>>> pp(dir(t0.get_rows()[0][1]))
['__abstractmethods__',
'__add__',
'__class__',
...
'updaters',
'updating_suspended',
'width',
'z_index']
>>>
>>> str(t0.get_rows()[0][1].lines_text)
"Text('is a')"
>>>
>>> str(t0.get_rows()[0][1].lines_text).split("'")[1]
'is a'
>>>
>>>
>>> txt = Text('Hello world')
>>>
>>> txt.color
ManimColor('#000000')
>>>
The t0 example comes straight from the Table example in the documentation.