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.

Provide example of widget executing nonblocking code

See original GitHub issue

Summary

Add something like this example to the documentation:

import threading
from IPython.display import display
import ipywidgets as widgets
import time
progress = widgets.FloatProgress(value=0.0, min=0.0, max=1.0)

def work(progress):
    total = 100
    for i in range(total):
        time.sleep(0.2)
        progress.value = (i+1)/total

thread = threading.Thread(target=work, args=(progress,))
display(progress)
thread.start()

Original Issue

From what we understand, ipywidgets is a serverextension + nbextension + custom messages that use the shell channel, which blocks on kernel executing code. Is it possible at all, to create a widget that is constantly refreshing its output regardless of whether the kernel’s shell channel is busy or not?

We’d be willing to contribute changes to ipywidgets if you can devise a way to make this possible.

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
maartenbreddelscommented, Jun 24, 2016

This example works: https://gist.github.com/maartenbreddels/3378e8257bf0ee18cfcbdacce6e6a77e It also works when you set thread_safe to False, but I know from experience that it will fail sometimes.

1reaction
SylvainCorlaycommented, Jun 26, 2016

I think that it is worth creating an example notebook for something like this (and a progress bar) …

Read more comments on GitHub >

github_iconTop Results From Across the Web

QT - Show Widget without blocking his GUI - Stack Overflow
You can take a look at Qt QProgressDialog class. If you need that the widget do not block the main GUI, you can...
Read more >
Overview of Blocking vs Non-Blocking - Node.js
Blocking. Blocking is when the execution of additional JavaScript in the Node.js process must wait until a non-JavaScript operation completes.
Read more >
4. Loading Scripts Without Blocking - Even Faster Web Sites ...
The reason browsers block while downloading and executing a script is that the script may make changes to the page or JavaScript namespace...
Read more >
Executing Nonblocking System Commands (Mastering Perl/Tk)
Here's a private method that reads command output and inserts it into the Text widget. It calls kill_command to perform cleanup operations when...
Read more >
Modal and Blocking Widgets - IDL Coyote
Was it possible to write a program that stopped and waited for user input when called both from within a widget program and...
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