question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google colab change form parameters

See original GitHub issue

I had a question which I asked here: https://stackoverflow.com/questions/68957902/google-colab-change-form-parameters, and it was not answered, therefore I guess this feature is not present in colab till now.

Therefore I would really like if making this feature would be possible, as it is needed.

Pasting the question from Stackoverflow

Google colab form has a powerful feature called Forms, https://colab.research.google.com/notebooks/forms.ipynb.

In that there is a dropdown option too, I want to modify the options of the drop-down list via code.

Is it possible to do so colab?

Example it should work in this manner:

n = input('Give a number : ')
arr = list(range(n))
dropdown = arr[0] #@param arr

I have tried the above code but it won’t work simply because the param list is after #, hence it commented as python cant reach till there.

If not should I use Jupyter Widgets? Would they be efficient, fast, and most importantly re-run cells on change?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bloiscommented, Nov 11, 2021

A simple example is something like: https://colab.research.google.com/gist/blois/71aa984fdab9a0b2ef6c9438dc06382e/altair-stock-comparison.ipynb

This is using @interact, but you can also use the Output widget to scope what is being cleared- https://ipywidgets.readthedocs.io/en/latest/examples/Output Widget.html

0reactions
CrDevUnocommented, Nov 11, 2021

For parameters which are dynamic (determined at runtime) the widgets approach used above is the recommended approach.

After the dropdown is displayed you can use fruit_picker.value to get the selected value.

For future references, can this issue stay open or mark it as feature request, please? - other users might be interested in this feature, too.

I’m searching about how to use ipywidgets in Google Colab, because, I have this scenario:

I created a dropdown with dynamic data (from a JSON object I bring using requests), once an item is selected, it will show the results in a graph, however, I want to achieve that each time the dropdown changes its selected value, the graph is regenerated; in this case, I’m cleaning the output, but, cleaning the output also deletes the dropdown and so far, I’m unable to redraw the dropdown OR print the results in another code cell.

What would be the correct approach in Google Colab for the described scenario?

Read more comments on GitHub >

github_iconTop Results From Across the Web

jupyter notebook - Google colab change form parameters
In that there is a dropdown option too, I want to modify the options of the drop-down list via code. Is it possible...
Read more >
Forms - Colaboratory
Forms provide an easy way to parameterize code. From a code cell, select Insert → Add form field. When you change the value...
Read more >
Google Colab - Adding Forms
Google Colab - Adding Forms, Colab provides a very useful utility called Forms ... Try changing this to a different value and Run...
Read more >
Welcome to Google Colab: Tricks and Tweaks (Part 3)
Try changing this to a different value and Run all to see its effect. Inputting Text. To accept a text input in your...
Read more >
adding a form to google colab to speed creation of ... - YouTube
Check out Horst's web page. He's a great guy and can help you learn how to code!https://spielend-programmieren.at/
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found