3.3.5. Text

The Text control is used to display text.

text_object.set_text(string, [color_r, color_g, color_b, color_a, ]align, size)
Description:

Sets text attributes of the control

Parameters:
  • string (string) – The content of the string to be displayed
  • [color_r, color_g, color_b, color_a] (list) – Optional parameters, which indicate the color of the string to be displayed. These parameters respectively indicate the r value, b value, g value, and transparency of the displayed color, and their value ranges are all [0, 255].
  • align (enum) – An optional enumeration-type parameter, which indicates the alignment mode of the text to be displayed. For details, see the align table.
  • size (int) – The font size of the displayed text
Returns:

None

Example:

my_Text.set_text(120, 120, 120, 200, text_anchor.upper_left, 12)

Example description:
 

Set the rgb value of text color to (120, 120, 120), the transparency to 200, the text alignment mode to top-left, and the font size to 12

text_object.set_text_color(r, g, b, a)
Description:

Sets the text color of the control

Parameters:
  • r (int) – The r value of text color, whose range is [0, 255]
  • g (int) – The g value of text color, whose range is [0, 255]
  • b (int) – The b value of text color, whose range is [0, 255]
  • a (int) – The transparency of text color, whose range is [0, 255]
Returns:

None

Example:

my_Text.set_text_color(120, 120, 120, 200)

Example description:
 

Set the rgb value of text to (120, 120, 120) and the transparency to 200

text_object.set_text_align(align)
Description:Set the text alignment mode
Parameters:align (enum) – An optional enumeration-type parameter, which indicates the alignment mode of the text to be displayed. For details, see the align table.
Returns:None
Example:my_Text.set_text_align(text_anchor.upper_left)
Example description:
 Set the text alignment mode to top-left
text_object.set_text_size(size)
Description:Set the text font size
Parameters:size (int) – Font size of text
Returns:None
Example:my_Text.set_text_size(12)
Example description:
 Set the font size of text to 12
text_object.set_border_active(active)
Description:Whether to display text borders
Parameters:active (bool) – Whether to display text borders, where True indicates to display borders, and False indicates not to display borders
Returns:None
Example:my_Text.set_border_active(True)
Example description:
 Display text borders
text_object.set_background_color(r, g, b, a)
Description:

Sets the background color of the control

Parameters:
  • r (int) – The r value of background color, whose range is [0, 255]
  • g (int) – The g value of background color, whose range is [0, 255]
  • b (int) – The b value of background color, whose range is [0, 255]
  • a (int) – The transparency of background color, whose range is [0, 255]
Returns:

None

Example:

my_Text.set_background_color(200, 200, 200, 230)

Example description:
 

Set the rgb value of background color to (200, 200, 200) and the transparency to 230

text_object.set_background_active(active)
Description:Whether to display the text background
Parameters:active (bool) – Whether to display the text background, where True indicates to display the background, and False indicates not to display the background
Returns:None
Example:my_Text.set_background_active(True)
Example description:
 Display the text background
text_object.append_text(content)
Description:Adds text to the Text control
Parameters:content (string) – The text that needs to be added to the Text control
Returns:None
Example:my_Text.append_text('RoboMaster EP')
Example description:
 Add the RoboMaster EP text to the Text control
align