pyjulia icon indicating copy to clipboard operation
pyjulia copied to clipboard

hook up display system

Open SimonDanisch opened this issue 6 years ago • 5 comments

Can we by default have python jlwrap objects be hooked up to the display system? It should just be a matter of overloading the correct repr methods. E.g. just attach these defitions to the python object:

def _repr_html_(self):
   return Main.repr(Main.eval('MIME"image/png"()'), self)

Or something like this ;)

SimonDanisch avatar Sep 16 '19 16:09 SimonDanisch

It's possible https://github.com/tkf/ipyjulia_hacks https://github.com/tkf/PyBase.jl but this requires a change in PyCall to do it without type-piracy: https://github.com/JuliaPy/PyCall.jl/issues/617

tkf avatar Sep 16 '19 18:09 tkf

Cool! I'll try it out... But it seems to me, that one wouldn't need anything complicated to get this working, right? Just add the repr methods to the wrapper class and we're done, wouldn't we?

SimonDanisch avatar Sep 17 '19 13:09 SimonDanisch

Just adding the repr methods to the wrapper class should be sufficient. In general, there are lots of small self-contained PRs that could potentially be written to enhance the functionality of the wrapper class a little at a time.

stevengj avatar Sep 17 '19 15:09 stevengj

Can you point me to where this could be done? It wasn't easy for me to find the place for such additions, since everything seems to be done via the c interface...

SimonDanisch avatar Sep 17 '19 15:09 SimonDanisch

https://github.com/JuliaPy/PyCall.jl/issues/617 is where it's happening

But you can also create a Python shim class (that's the trick I used in PyBase and ipyjulia_hacks).

tkf avatar Sep 17 '19 20:09 tkf