Hello! I am opening this issue because the workaround example on wiki for the google colab userdata.get() is outdated. The ipywidget library does not support the on_submit anymore.
What you think of updating the example like below? Basically we need to change the .on_submit for .observe and add continuous_update=False.
import os
import ipywidgets as widgets
from IPython.display import clear_output, display
def input_secret(secret_name):
def handle_submit(sender):
user_value = sender['new']
os.environ[secret_name] = user_value
print(f"Environment variable {secret_name} set")
with output_area:
clear_output()
# Create a text input widget
text_input = widgets.Text(
value='',
placeholder=f'Value for {secret_name}',
description=f'Secret Value',
disabled=False,
continuous_update=False
)
# Create an output widget to control clearing
output_area = widgets.Output()
# Link the submit event to the handler function
text_input.observe(handle_submit, names='value')
# Display the widget inside the output area, then display the output area
with output_area:
display(text_input)
display(output_area)
input_secret("GEMINI_API_KEY")
Hello! I am opening this issue because the workaround example on wiki for the google colab userdata.get() is outdated. The ipywidget library does not support the
on_submitanymore.What you think of updating the example like below? Basically we need to change the
.on_submitfor.observeand addcontinuous_update=False.