Create Programmatic Dynamic Forms
Graph Studio allows you to programmatically create dynamic forms using the Java (PGX) and Python (PGX) interpreters.
As a prerequisite step, you must first import the context that allows you to display the forms and define your own variable name and instantiate your context.
import oracle.datastudio.interpreter.common.context.JavaDataStudioContext
JavaDataStudioContext ds = interpreter.getJavaDataStudioContext()from ds_interpreter_client.context.ds_context import PyDataStudioContext
ds = PyDataStudioContext()ds context allows you to display the forms and
            define your own variable name.
                  The following steps describe the programmatic creation of the Textbox, Select, Select Multiple, Slider, Checkbox, Date Picker, Time Picker, and DateTime Picker forms. It is important to note that only when you run the notebook paragraph with the dynamic form value (or the default value), then the values are persisted on page reload.
- Create a Textbox dynamic form which allows you to input any string of
                    characters.
ds.textbox("<name>", "<default_value>")In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.default_value(optional): The default value that is given to the dynamic form when it is first created.
For example:

Description of the illustration java_text_box.pngds.textbox(name="<name>", default_value="<default_value>")In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.default_value(optional): The default value that is given to the dynamic form when it is first created.
For example:

Description of the illustration python_text_box.png - Create a Select dynamic form which allows you to select a value from a
                    drop-down menu.
import oracle.datastudio.common.forms.ParamOption List<ParamOption<String>> options = new ArrayList<>() options.add(new ParamOption<>("<option_value_a>", "<option_label_a>")) options.add(new ParamOption<>("<option_value_b>", "<option_label_b>")) ds.select("<name>", options, "<default_value>")In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.default_value(optional): The default value that is given to the dynamic form when it is first created.
For example:

Description of the illustration java_select.pngoptions = [("<option_value_a>", "<option_label_a>"),("<option_value_b>", "<option_label_b>")] ds.select(name="<name>", options=options, default_value="<default_value>")In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.default_value(optional): The default value that is given to the dynamic form when it is first created.
For example:

Description of the illustration python_select.png - Create a Select Mulitple dynamic form which allows you to select one or
                    more values from a drop-down list.
List<ParamOption<String>> options = new ArrayList<>(); options.add(new ParamOption<>("<option_value_a>", "<option_label_a>")); options.add(new ParamOption<>("<option_value_b>", "<option_label_b>")); List<String> defaultValues = new ArrayList<>(); defaultValues.add("<default_value>"); ds.selectMultiple("<name>", options, defaultValues, "<label>")In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.label(optional): The label that is displayed on top of the dynamic form.default_value(optional): The default value that is given to the dynamic form when it is first created. It must be one of the option values.- An option comprises
                                            
option_valueandoption_label. Theoption_valueis used to reference whichdefault_valueshould be selected, and the (optional)option_labelis displayed in the drop-down list. - An 
option_valuecan be either a string or a numeric value. - Options are separated with the
                                            
|character in parsed forms. 
- An option comprises
                                            
 
For example:
options = [('<option_value_a>', '<option_label_a>'),('<option_value_b>', '<option_label_b>')] ds.select_multiple(name='<name>', options=options, default_value=['<default_value>'], label='<label>')In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.label(optional): The label that is displayed on top of the dynamic form.default_value(optional): The default value that is given to the dynamic form when it is first created. It must be one of the option values.- An option comprises
                                            
option_valueandoption_label. Theoption_valueis used to reference whichdefault_valueshould be selected, and the (optional)option_labelis displayed in the drop-down list. - An 
option_valuecan be either a string or a numeric value. - Options are separated with the
                                            
|character in parsed forms. 
- An option comprises
                                            
 
For example:
 - Create a Slider dynamic form which allows you to choose a number from a
                    given range.
ds.slider("<name>", <minimum>, <maximum>, <step_size>, <default_value>)In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.minimum: The minimum value of the slider. Must be a number.maximum: The maximum value of the slider. Must be a number.step_size: The step size of the slider. Must be a number and divider of (maximum - minimum).default_value(optional): The default value that is given to the dynamic form when it is first created (minimum <= default_value <= maximum).
For example:

Description of the illustration java_slider.pngds.slider(name="<name>", min=<minimum>, max=<maximum>, step=<step_size>, default_value=<default_value>)In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.minimum: The minimum value of the slider. Must be a number.maximum: The maximum value of the slider. Must be a number.step_size: The step size of the slider. Must be a number and divider of (maximum - minimum).default_value(optional): The default value that is given to the dynamic form when it is first created (minimum <= default_value <= maximum).
For example:

Description of the illustration python_slider.png - Create a Checkbox dynamic form which allows you to select one or
                    multiple values.
import oracle.datastudio.common.forms.ParamOption List<ParamOption<String>> options = new ArrayList<>() options.add(new ParamOption<>("<option_value_a>", "<option_label_a>")) options.add(new ParamOption<>("<option_value_b>", "<option_label_b>")) List<String> defaultValues = new ArrayList<>() defaultValues.add("<default_value>") ds.checkbox("<name>", options, defaultValues)In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.default_value(optional): The default value that is given to the dynamic form when it is first created. It must be one of the option values:- An option comprises
                                            
option_valueandoption_label. Theoption_valueis used to reference whichdefault_valueshould be selected, and the (optional)option_labelis displayed in respective boxes created by a checkbox. - An 
option_valuecan be either a string or a numeric value. - Options are separated with the
                                            
|character in parsed forms. 
- An option comprises
                                            
 
For example:

Description of the illustration java_checkbox.bmpoptions = [("<option_value_a>", "<option_label_a>"),("<option_value_b>", "<option_label_b>")] ds.checkbox(name="<name>", options=options, default_value=["<default_value>"])In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.default_value(optional): The default value that is given to the dynamic form when it is first created. It must be one of the option values:- An option comprises
                                            
option_valueandoption_label. Theoption_valueis used to reference whichdefault_valueshould be selected, and the (optional)option_labelis displayed in respective boxes created by a checkbox. - An 
option_valuecan be either a string or a numeric value. - Options are separated with the
                                            
|character in parsed forms. 
- An option comprises
                                            
 
For example:

Description of the illustration python_checkbox.png - Create a Date Picker dynamic form which allows you to select a
                    date.
ds.datePicker("<name>", "<date_format>", "<default_value>")In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.date_format(optional, recommended): The date format that is used for displaying the selected date in the input field and for formatting the resulting date when the paragraph is run.default_value(optional): The default value that is given to the dynamic form when it is first created. It must be specified according to thedate_formator inyyyy-MM-ddformat if thedate_formatis not provided.
For example:

Description of the illustration java_date.pngds.date_picker(name="<name>", format="<date_format>", default_value="<default_value>")In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.date_format(optional, recommended): The date format that is used for displaying the selected date in the input field and for formatting the resulting date when the paragraph is run.default_value(optional): The default value that is given to the dynamic form when it is first created. It must be specified according to thedate_formator inyyyy-MM-ddformat if thedate_formatis not provided.
For example:

Description of the illustration python_date_picker.png - Create a Time Picker dynamic form which allows you to select a
                    time.
ds.timePicker("<name>", "<time_format>", "<default_value>")In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.time_format(optional, recommended): The time format that is used for displaying the selected time in the input field and for formatting the resulting time when the paragraph is run.default_value(optional): The default value that is given to the dynamic form when it is first created. It must be specified according to thetime_formator inHH:mmformat if thetime_formatis not provided.
For example:

Description of the illustration java_time.pngds.time_picker(name="<name>", format="<time_format>", default_value="<default_value>")In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.time_format(optional, recommended): The time format that is used for displaying the selected time in the input field and for formatting the resulting time when the paragraph is run.default_value(optional): The default value that is given to the dynamic form when it is first created. It must be specified according to thetime_formator inHH:mmformat if notime_formatis provided.
For example:

Description of the illustration python_time_picker.png - Define a DateTime Picker dynamic form which allows you to select a date
                    and a time.
ds.dateTimePicker("<name>", "<dateTime_format>", "<default_value>")In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.dateTime_format(optional, recommended): ThedateTimeformat that is used for displaying the selected date and time in the input field and for formatting the resulting date and time when the paragraph is run.default_value(optional): The default value that is given to the dynamic form when it is first created. It must be specified according to thedateTime_formator inyyyy-MM-dd HH:mmformat if thedateTime_formatis not provided.
For example:

Description of the illustration java_date_time.pngds.date_time_picker("<name>", format="<dateTime_format>", default_value="<default_value>")In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.dateTime_format(optional, recommended): ThedateTimeformat that is used for displaying the selected date and time in the input field and for formatting the resulting date and time when the paragraph is run.default_value(optional): The default value that is given to the dynamic form when it is first created. It must be specified according to thedateTime_formator inyyyy-MM-dd HH:mmformat if thedateTime_formatis not provided.
For example:

Description of the illustration python_date_time_picker.png 
Customize Dynamic Form Layout
You can use the columnSpan and nextRow
        parameters to enhance data entry and readability in dynamic form layouts.
                  
- Small screens: Forms collapse to four columns (one form per row).
 - Medium screens: 8-column grid (two forms per row).
 - Large screens: Full 12-column grid (three forms per row).
 
As a prerequisite step, you must first import the context that allows you to display the forms and define your own variable name and instantiate your context.
import oracle.datastudio.interpreter.common.context.JavaDataStudioContext
JavaDataStudioContext ds = interpreter.getJavaDataStudioContext()from ds_interpreter_client.context.ds_context import PyDataStudioContext
ds = PyDataStudioContext()- The following example describes how to programmatically create a half-width
                    Textbox (6 columns):
ds.textbox("<name>", "<defaultValue>", <"label">, <columnSpan> )In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form if no <label> is set. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.defaultValue(optional): The default value that is given to the dynamic form when it is first created.label(optional): The label that is displayed on top of the dynamic form.columnSpan: Number of columns (out of 12) a form occupies. The default value is four (three forms per row).
For example:
ds.textbox(name="<name>", default_value="<default_value>", label="<label>", column_span="<column_span_value>"))In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form if no <label> is set. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.default_value(optional): The default value that is given to the dynamic form when it is first created.label(optional): The label that is displayed on top of the dynamic form.column_span: Number of columns (out of 12) a form occupies. The default value is four (three forms per row).
For example:
 - The following example describes how to programmatically create a form on a new
                    row:
ds.textbox("<name>", "<defaultValue>", <"label">, <columnSpan>, <nextRow> )In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form if no <label> is set. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.defaultValue(optional): The default value that is given to the dynamic form when it is first created.label(optional): The label that is displayed on top of the dynamic form.columnSpan: Number of columns (out of 12) a form occupies. The default value is four (three forms per row).nextRow: A boolean parameter that determines if the form should start on a new row or not. Note that you must explicitly setcolumnSpanwhen usingnextRow.
For example:
ds.textbox(name="<name>", default_value="<default_value>", label="<label>", column_span="<column_span_value>, next_row="<next_row_value>"))In the preceding code:
name: The name of the dynamic form. It is displayed on top of the dynamic form if no <label> is set. If you want to reference a dynamic form multiple times in a paragraph, you can assign the samenameto do so and it will only be displayed once.default_value(optional): The default value that is given to the dynamic form when it is first created.label(optional): The label that is displayed on top of the dynamic form.column_span: Number of columns (out of 12) a form occupies. The default value is four (three forms per row).next_row: A boolean parameter that determines if the form should start on a new row or not.
For example:
 





