简体   繁体   English

如何创建一个包含空单元格的表格?

[英]How to create a table with empty cells?

When using Manim, how to create a table such that in the first row there are letters of the word "HELLO", and in the second row there are empty cells?使用 Manim 时,如何创建一个表,使其第一行有单词“HELLO”的字母,第二行有空单元格?

Python code: Python 代码:

t3 = Table(
    [["H", "E", "L", "L", "O"],
    [" ", " ", " ", " ", " "]], include_outer_lines=True,
    line_config={"stroke_width": 5, "color": BLUE}, v_buff = 1.3).scale(0.8)

self.play(FadeIn(t3, run_time=2))

My result:我的结果:

在此处输入图像描述

A dirty trick would be to set the cells of the empty row the same as the one above, but also change its opacity to 0 :一个肮脏的技巧是将空行的单元格设置为与上面的单元格相同,但还将其不透明度更改为0

输出

from manim import *

class EmptyTableCells(Scene):
    def construct(self):

      t = Table(
      [["H", "E", "L", "L", "O"],
      ["H", "E", "L", "L", "O"]], include_outer_lines=True,
      line_config={"stroke_width": 5, "color": BLUE}, v_buff = 1.3).scale(0.8)

      t.get_rows()[1].set_opacity(0) # change the second row's text opacity
      self.play(FadeIn(t, run_time=2))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM