Skip to main content

Code Input

Accepts code input with syntax highlighting

Examples

Basic Example

The following example demonstrate some of the available functionality for read_code

from abstra.forms import read_code

ans = read_code(
"Show me the code!",
language="c",
initial_value="""\
#include<stdio.h>
int main(int argc, char** argv) {
char name[256];
scanf("%s", name);
printf("%s, here is", name);
return 0;
}""",
)

Parameters

NameDescriptionType
labelThe label to display to the userstr
initial_valueThe initial value to display to the user. Defaults to "".str
languageThe programming language. Defaults to None.str
disabledwhether the input is disabled. Defaults to False.bool
requiredWhether the input is required or not eg. "this field is required". Defaults to True.Union[bool, str]
hintA tooltip displayed to the user. Defaults to None.str
end_programWhether the program should end after the widget is shown. Defaults to False.bool
full_widthWhether the input should use full screen width. Defaults to False.bool
button_textWhat text to display on the button when the widget is not part of a Page. Defaults to 'Next'.str

Return Values

TypeDescription
strThe value entered by the user