Comments (11)
Here's my workaround:
import traceback
class MyUI:
def __init__(self, canvas, model):
self.canvas = canvas
self.model = model
canvas.on_mouse_down(self.mouse_down)
def mouse_down(self, x, y):
try:
do_some_stuff()
except:
self.print_traceback()
def print_traceback(self):
self.canvas.fill_style = '#ff8888'
self.canvas.fill_rect(10, 10, 300, 300)
self.canvas.fill_style = '#000000'
s = traceback.format_exc()
for i, si in enumerate(s.split('\n')):
canvas.fill_text(si, 20, 30+15*i)
Works great. Now my code is debugable.
from ipycanvas.
Thanks a lot for opening an issue. I suppose this is unexpected behavior. I am not sure what is causing this. I will have a look in two weeks.
from ipycanvas.
that's a really neat workaround, thanks @kenseehart
from ipycanvas.
That is really weird. I could also see something similar in ipyleaflet today, see jupyter-widgets/ipyleaflet#455 (comment).
I really don't know where this comes from.
Maybe you already know about it, but you can use the Output
widget in order to capture the stream explicitly, and put it where you want.
from ipycanvas.
Yes - the issue is more for debugging when it's hard to know where to capture output. I don't know why this might be happening, but the jupyter lab log console is discussed here: jupyterlab/jupyterlab#7386
They specifically mention un-handled messages being logged; I don't know how a message being "handled" is defined though.
from ipycanvas.
Looks like the CallbackDispatcher is consuming stdin and stdout for some reason. It's not about exceptions per se. Probably the exception is be handled in the normal way, but when the traceback is written to stdout, it gets consumed.
from ipycanvas.
The CallbackDispatcher is being created a little bit differently in ipycanvas and the ipywidgets button. In the button it is created in the constructor:
https://github.com/jupyter-widgets/ipywidgets/blob/6be18d9b75353f7b4a1c328c6ea06d8959f978f6/ipywidgets/widgets/widget_button.py#L57-L60
whereas here it is wrapped in at traitlets Instance
function and explicitly added:
https://github.com/martinRenou/ipycanvas/blob/a97d7810745afb61e4daed71bd92b998304e36fd/ipycanvas/canvas.py#L180
from ipycanvas.
@ianhi do you think that could be the cause of the issue?
Indeed having the object instantiated as a kind-of static property does not sound right at all.
from ipycanvas.
@martinRenou oops I forgot to include any context for that comparison. Yes, my intention was to imply that this may be the cause as this seems to be the only relevant difference between ipycanvas and the ipywidgets.Button
from ipycanvas.
Hi! Why is this issue closed? Is it fixed in the new versions?
from ipycanvas.
Hi @ahrm this issue is still open. You see this at the top of the page:
from ipycanvas.
Related Issues (20)
- How to get the new path HOT 7
- add width, height support to put_image_data HOT 1
- How to add transform to Path2D HOT 6
- voila fails to load ipycanvas.js from localhost HOT 2
- how to drag an image around on the canvas? HOT 2
- bundle text and shape into one object HOT 4
- ipycanvas does not work with JupyterLab 4 HOT 4
- debug_output only works if calling display(canvas) HOT 1
- ipycanvas 0.13.1 does not work with google colab. 0.13 works. HOT 1
- Take a screenshot of a drawing/canvas and save it? HOT 2
- current canvas out of sync after page reload
- Commands JSON content mangled HOT 3
- Error displaying widget: model not found HOT 1
- is there no call to remove a shape? HOT 1
- bug on canvas.clear() HOT 1
- any way to pause animation? HOT 2
- feature request for mouse drag HOT 2
- Using Path2D for stroke
- Error with fresh jupyterlab 3 install - "Failed to load model class" / "Error: No version of module ipycanvas is registered" HOT 3
- The docs link to github needs updating HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipycanvas.