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.

Widget text not getting synchronized value

See original GitHub issue

Hi, I tried to get fresh text.value after submitting…but it seems to give out old values (submitted previously or empty string)

text = widgets.Text()
display(text)

def handle_submit(sender):
    print(text.value)
    
text.on_submit(handle_submit)

I actually follow the example from this website, and expect to have similar effect…

I installed ipywidgets through conda today (tried to pip install / install from git but failed, possibly because of some broken conda settings on my desktop…)

Just want to know if there’s a way to get synchronized text widget value ? Also, it seems that the on_submit event is outdated? Is there a better way to achieve the same submitting event?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jasongroutcommented, Nov 28, 2017

The recommended way to do this is to do something like:

import ipywidgets as widgets
from IPython.display import display

# You could also pass in continuous_update=False to only send 
# the new value when pressing enter or leaving the textbox
t = widgets.Text()

def value_changed(change):
    # change.new contains the new value
    print('new value: ' + change.new)

# call the value_changed function when t.value changes
t.observe(value_changed, 'value')

display(t)
0reactions
rpedselcommented, Nov 28, 2017

Thanks for your recommendation! I tried to apply observe function before, but nothing happened after I click enter. It turns out that I need to click ctrl + enter to submit the text. Also, lots of thanks to ipywidgets developers! I am bad at web dev and this tool really helps me a lot to deliver a simple UI easily 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to synchronise two TextFields in Flutter - Stack Overflow
I'd like to sync them so when user updates the net price, the gross price is automatically calculated and updated. When the user...
Read more >
Widget Events — Jupyter Widgets 7.7.0 documentation
When synchronizing traitlets attributes, you may experience a lag because of the latency due to the roundtrip to the server side. You can...
Read more >
auto_size_text | Flutter Package - Pub.dev
Flutter widget that automatically resizes text to fit perfectly within its bounds. ... Usually, this value should not be below 1 for best...
Read more >
New Component: streamlit-ext, sync widgets' value with url
When widgets value changes, the url synced and if you open the url in new tab, every value keeped. Just import widgets from...
Read more >
Offline-First | Mendix Documentation
Please note that a nanoflow object variable's value might become empty after synchronization, if the object is removed from the device during ...
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