Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

surface.ipython_display() fails in python 3 #31

Open
ghost opened this issue Apr 26, 2017 · 1 comment
Open

surface.ipython_display() fails in python 3 #31

ghost opened this issue Apr 26, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 26, 2017

The following snippet produces no output in jupyter with python3.

import gizeh as gz
W, H = 500, 300
r, gray, t = 25., .3, 1.

surface = gz.Surface(W,H, bg_color=(1, 1, 1)) # white background
gradient = gz.ColorGradient(type="radial", stops_colors=[(0,(gray, gray, gray)), (1, (1, 1, 1))],
                            xy1=[0, 0], xy2=[0, 0], xy3=[0, r])
rf = gz.circle(r=r, xy=(W/2., H/2.), fill=gradient)
#rect = gz.rectangle(lx=.3*H, ly=.02*H, xy=(W*t/duration, H/2.), fill=(0,1,0), angle=np.pi/2)

rf.draw(surface)
surface.ipython_display()

The problem is in Surface._repr_png_(). Python 3 doesn't have the cStringIO module, so the line data = StringIO() fails (silently). If I instead use the io module as suggested here, the snippet above generates an error from cairo.

@YPares
Copy link

YPares commented Jun 8, 2018

I found that extension for jupyter https://github.com/fomightez/cairo-jupyter

Is there a way to access the underlying cairo surface/context of a gizeh surface?

EDIT: Yes, with _cairo_surface. And it seems to work alright :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant