qtconsole icon indicating copy to clipboard operation
qtconsole copied to clipboard

add an option to restore HTML support to qtconsole

Open Gitman-code opened this issue 9 years ago • 12 comments

Migrating issue from ipython/ipython/issues/10062

@ccordoba12 suggested to open a QDialog with a QWebView widget inside it to display HTML content in qtconsole?

Much of the desire for this is related to the HTML DataFrames in Pandas being human readable. see pandas-dev/pandas#14706

Gitman-code avatar Nov 25 '16 07:11 Gitman-code

Thanks for migrating this issue. I have one problem with my own suggestion: we could end up opening a lot of Qdialog's and that could be messy for users.

@wmvanvliet, what do you think about this?

ccordoba12 avatar Nov 25 '16 15:11 ccordoba12

I think popping open dialogs for output would break the flow of using a console.

Longer term, we have suggested implementing a console in HTML & JS, and using Qt Webkit to embed this in Qt applications.

takluyver avatar Nov 25 '16 19:11 takluyver

Ok, what if at the end of html output we show a link so that users can open these dialogs at will?

ccordoba12 avatar Nov 26 '16 18:11 ccordoba12

That is an interesting idea but I am not sure it would solve the issue which gave rise to my original ticket. If I understand you correctly you would need to click the link each time to show the object in HTML format. The reason I started looking into how to get this functionality back was specifically for DataFrames in Pandas. Analysts/scientists, such as myself, use the DataFrame output for an interactive and exploratory work-flow. The HTML DataFrames were much better formatted (in most cases) for this. If one would need to click a link each time there would be a significant level of annoyance relative to the original functionality. Would it be possible to set it up so that the user could set a white-list of objects which always automatically open the dialog? Users could then enable it for DataFrames and the rest would need a link clicked before shown.

Gitman-code avatar Nov 26 '16 22:11 Gitman-code

Another idea is to show those links and a message saying how to open those dialogs automatically (else almost no one would activate this functionality).

@DrEhrfurchtgebietend, what do you think?

ccordoba12 avatar Nov 26 '16 23:11 ccordoba12

That seems even better to me. Assuming of course that the message in the Out[#] would not be so verbose that it annoys those who are not looking for that option.

Gitman-code avatar Nov 27 '16 03:11 Gitman-code

Yep, that'd be the idea :-)

ccordoba12 avatar Nov 27 '16 15:11 ccordoba12

+1 for the link option for me. Lets keep the qtconsole a plain text console as much as possible.

A full HTML implementation of the console is already being worked on as part of JupyterLab I believe.

wmvanvliet avatar Dec 13 '16 07:12 wmvanvliet

Maybe not worth it versus a jupyterlab console in a webengine widget, but using a qstackedlayout you can mix rich text and webengine widgets. Each input and output could be their own widget in the stack. Most of the widgets would just be the existing qtconsole richtext widgets, but when the output is HTML we could use webengine widgets.

The widgets in the stacks could even be limited in height and width so they could scroll content vertically and horizontally if the context need, like paging in some respects.

bcolsen avatar Oct 17 '18 22:10 bcolsen

I was thinking to do something simpler: emit HTML content in a Qt signal that would be captured by apps embedding qtconsole widgets (like Spyder) and rendered in a Web viewer pane or widget.

I think that's how RStudio's Viewer pane works and it's really nice:

https://www.youtube.com/watch?v=wi2fUKqHtpM

ccordoba12 avatar Oct 17 '18 23:10 ccordoba12

I noticed this issue is still open. I am keen to render HTML objects without using Jupyter notebooks or lab either within the qtconsole or in a separate window. Is this still being considered?

DancingQuanta avatar May 30 '20 18:05 DancingQuanta

Hey, am I in the right place here wondering why I can't do one of these in the qtconsole?

from IPython.display import display, HTML
display(HTML('<h1>Hello, world!</h1>'))

where the output is this:

<IPython.core.display.HTML object>

The actual thing I was trying to do was something like this

display(HTML(difflib.HtmlDiff().make_file(a, b)))

It sounds like the original reason for removing support in https://github.com/ipython/ipython/pull/5763 was "pandas felt that the HTML repr was bad". I agree with the comment in https://github.com/ipython/ipython/issues/10062

But we could have an off-by-default option to enable HTML in the QtConsole for users who prefer semi-supported HTML output to none at all.

although who does it harm to enable the HTML output for all by default? People who don't like it won't use it and I assume it's a niche thing to be working in a qtconsole and trying to view html.

digitalsignalperson avatar Jun 01 '23 05:06 digitalsignalperson