Zulko / gizeh

Simple Vector Graphics for Python
Other
709 stars 69 forks source link

Show image of surface as representation in IPython. #16

Closed eriknw closed 9 years ago

eriknw commented 9 years ago

_repr_html_ and _repr_png_ methods were added, which are used by IPython.

Also, don't write to "temp.png" anymore. Instead, write temporary png data to a StringIO object. Tested and works in both Python 2 and 3.

Zulko commented 9 years ago

Is ipython_display still necessary now that there is repr_png, or is there a better way to display in ipython now ?

eriknw commented 9 years ago

Up to you. Keeping Surface.ipython_display as a method allows you to add customizations through keyword arguments, such as y_origin= (which I haven't messed with).

Typically, IPython.display.display (or one of its relatives) is used if you want to display an item--or several items--in an IPython notebook. This lets you do

IPython.display.display(surface1)
IPython.display.display(surface2)
# or, better yet,
IPython.display.display(surface3, surface4)

in a single cell to display multiple items.

Shall I remove Surface.ipython_display? I probably would if it were up to me, but I don't know how important customization might be.

Zulko commented 9 years ago

Let's leave ipython_display for the moment, I like the y_origin option (maybe an alternative is to set_y_origin() prior to rendering, to avoid having to specify it in the ipython_display).

Thanks for the commit !