from manim import *
class T041_06(Scene):
    def construct(self):
        data = [["90", "100", "60"], ["66", "78", "83"]]
        cols = [Text("小红"), Text("小华"), Text("小明")]
        rows = [Text("语文"), Text("数学")]
        # 1. 按行设置颜色
        t1 = Table(data, row_labels=rows, col_labels=cols)
        t1.set_row_colors(BLUE, RED, YELLOW)
        # 2. 按列设置颜色
        t2 = Table(data, row_labels=rows, col_labels=cols)
        t2.set_column_colors(BLUE, RED, YELLOW, GREEN)
        # 3. 获取行对象并加框
        t3 = Table(data, row_labels=rows, col_labels=cols)
        r = t3.get_rows()
        self.play(*[FadeIn(_o) for _o in [SurroundingRectangle(r[1])]], run_time=1.0)
        # 4. 获取列对象并加框（用独立变量，避免覆盖 cols）
        t4 = Table(data, row_labels=rows, col_labels=cols)
        c = t4.get_columns()
        self.play(*[FadeIn(_o) for _o in [SurroundingRectangle(c[1]), SurroundingRectangle(c[min(3, len(c) - 1)])]], run_time=1.0)
        g = Group(t1, t2, t3, t4).arrange(DOWN, buff=0.35)
        g.scale(min(1.0, 12.0 / max(g.width, 0.001), 6.5 / max(g.height, 0.001)))
        self.play(*[FadeIn(_o) for _o in [g]], run_time=1.0)
        self.play(FadeIn(g))
        self.wait(0.5)
        self.wait(1.10)