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.

Flickering when using as widget

See original GitHub issue

I am trying to animate a graph using ipywidgets but the output is flickering.

Is there a native way to embed the widget in ipywidgets? I am trying to figure it out from the docs, but they seem to be incomplete. The CytoscapeWidget has a callback to widgets, perhaps you can send me in the right direction?

from ipycytoscape import CytoscapeWidget
import networkx as nx
class Visualizer:
    def __init__(self, graph):
        self.graph = graph
        self.widget= CytoscapeWidget()
        self.widget.graph.add_graph_from_networkx(graph)
        self.update_nodes()
        style = [
        dict(selector = 'node',
              css = {
                  "background-color": "data(color)",
                  "text-outline-width" : 10
                    }),
        dict(selector = ':selected',
            css = {"background-color" : 'red',
                   "line-color" : "black",
                   "source-arrow-color" : "yellow",
                   "target-arrow-color" : "purple"})]
        self.widget.set_style(style)
    def update_nodes(self, data = None):
        if data:
            for idx, c in enumerate(data):
                node = self.widget.graph.nodes[idx]
                node.data['color'] = c
        else:
            for node in self.widget.graph.nodes:
                if np.random.rand() < .5:
                    node.data['color'] = 'red'  
                else:
                    node.data['color'] = 'blue'

g = nx.complete_graph(10)
v = Visualizer(g)
ts = iw.IntSlider(min = 0, max = 10, step = 1)
print(iw.widgets.interaction.__file__)
def callback(*args, **kwargs):
    kwargs.get('x')
    v.update_nodes()
display(v.widget)
plot = iw.interactive(callback, x = ts)
plot

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13

github_iconTop GitHub Comments

1reaction
cvanelterencommented, Oct 22, 2020

Ok I torched my env and reinstalled it. All is good now. Update looks good! Also saves the layout thanks a bundle!

1reaction
ianhicommented, Oct 21, 2020

Just naively, I believe the issue is that the whole widget is being redrawn. Let me know if I can help!

@cvanelteren you’re spot on with the diagnosis. I think there are actually two redraws happening.

  1. Becuase you use interactive ipywidgets will redraw the output
    • instead I would do: ts.observe(callback, names='value')
  2. ipycytoscape was redrawing the graph every time
Read more comments on GitHub >

github_iconTop Results From Across the Web

iOS Home Screen Widget Flicker in Gallery - Apple Developer
My iOS 14 home screen widget intermittently flickers in the widget gallery view. This happens sometimes when I run the widget from the...
Read more >
Widgets flickering in new iPhone. Should I use the warranty ...
Have you tried synchronizing your blinking with the flashing of the screen to eliminate all traces of it?
Read more >
Widget flickers on my website - LightWidget
How to fix the flickering? · They want to have different size of the widget for desktop and different for mobile. It can...
Read more >
Flickering Widgets | MacRumors Forums
"The flickering is often triggered after installing app updates or when the user re-configures a widget in its main app.".
Read more >
Is there a way to solve the iOS 14 Widget flicker issue?
The problem seems to occur after an app update gets installed. During development I thought this is a problem with the iOS Simulator,...
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