[reportlab-users] Display drawings in Jupyter notebooks

Andy Robinson andy at reportlab.com
Tue Mar 17 12:59:26 EDT 2020


Hi Dinu,  great to hear from you again.

I don't do any work in scientific Python or Jupyter, but if we can add
some harmless 'magic methods' to facilitate this, we will be happy to.

I suspect we may finally have more time for some core product
development in the next few months ;-)

- Andy

On Tue, 17 Mar 2020 at 16:51, Dinu Gherman <gherman at darwin.in-berlin.de> wrote:
>
> Hello and long time no see!
>
> I was looking at the GitHub issue tracker,
> https://github.com/MrBitBucket/reportlab-mirror/issues, but found only
> one (closed) one, so maybe this mailing list is still the better place
> to go (?).
>
> I'm using JupyterLab a lot these days and recently used some of
> ReportLab, again. So I've quickly found that drawings don't render
> implicitly in Jupyter notebook output cells. Sure you can do it with
> one line of code, but you don't want to do that again and again.
>
> But making such drawings display nicely in output cells is really easy
> by adding methods like "Drawing._repr_svg_(self)" or
> "Drawing._repr_png_(self)" or even "Drawing._repr_pdf_(self)" which
> will trigger http://mozilla.github.io/pdf.js to render the PDF output.
> I have created a sample notebook gist to illustrate this (only one
> interactive bit, a slider, is missing when you see it on GitHub):
>
> https://gist.github.com/deeplook/baaf91b1f79f5f5290e22283d17c6d6b
>
> My questions appear at the bottom of this notebook and are repeated
> here. They are all related to the fact that one could implement
> multiple displaying options for different formats at once and I can't
> figure out an ideal way of choosing between them:
>
> - Add one or more methods like _repr_svg_, _repr_png_, and _repr_pdf_
> (they do have some ranking inside Jupyter cells)?
> - How to choose between multiple methods (if given) like _repr_svg_,
> _repr_png_, and _repr_pdf_ at runtime?
> - Use a flag passed during object instantiation, Drawing(...,
> display_format="PNG")?
>
> Any ideas?
>
> Thanks,
>
> Dinu
>
>
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
> https://pairlist2.pair.net/mailman/listinfo/reportlab-users



-- 
Andy Robinson
Managing Director, ReportLab
Wimbletech Zone 2
35 Wimbledon Hill Road
London SW19 7NB, UK
Tel +44-20-8191-7277


More information about the reportlab-users mailing list