3.3.6. InputField

The InputField control is used to receive text information input by users.

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

Sets the text attributes in the input box object

参数:
  • 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
返回:

None

Example:

my_InputField.set_text('Hello RoboMaster',120, 120, 120, 200, text_anchor.upper_left, 12)

Example description:
 

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

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

Sets the color of text

参数:
  • 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]
返回:

None

Example:

my_button.set_text_color(120, 120, 120, 200)

Example description:
 

Set the RGB value of the font to (120, 120, 120) and the transparency to 200

input_field_object.set_text_align(align)
Description:Sets the alignment mode of text in the control
参数:align (enum) – An optional enumeration-type parameter, which indicates the alignment mode of the text to be displayed. For details, see the align table.
返回:None
Example:my_Input_field.set_text_align(text_anchor.upper_left)
Example description:
 Set the text alignment mode to top-left
input_field_object.set_text_size(size)
Description:Sets the font size of text in the control
参数:size (int) – Font size of text
返回:None
Example:my_Input_field.set_text_size(12)
Example description:
 Set the font size of text to 12
input_field_object.set_background_color(r, g, b, a)
Description:

Sets the background color of the control

参数:
  • 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]
返回:

None

Example:

my_Input_field.set_background_color(200, 200, 200, 230)

Example description:
 

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

input_field_object.set_hint_text(string, [color_r, color_g, color_b, color_a, ]align, size)
Description:

Sets the attributes of prompt text in the control

参数:
  • 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
返回:

None

Example:

my_Input_field.set_hint_text(120, 120, 120, 200, text_anchor.upper_left, 12)

Example description:
 

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

input_field_object.set_hint_text_color(r, g, b, a)
Description:

Sets the color of control prompt text

参数:
  • 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]
返回:

None

Example:

my_Input_field.set_text_color(120, 120, 120, 200)

Example description:
 

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

input_field_object.set_hint_text_align(align)
Description:Sets the alignment mode of prompt text
参数:align (enum) – An optional enumeration-type parameter, which indicates the alignment mode of the text to be displayed. For details, see the align table.
返回:None
Example:my_Input_field.set_text_align(text_anchor.upper_left)
Example description:
 Set the alignment mode of prompt text to top left
input_field_object.set_hint_text_size(size)
Description:Sets the font size of prompt text
参数:size (int) – Font size of text
返回:None
Example:my_Input_field.set_text_size(12)
Example description:
 Set the font size of the text in the hint object to 12