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

Refactored and improved Qt console's HTML export facility #281

Merged
0 commits merged into from Mar 12, 2011
Merged

Refactored and improved Qt console's HTML export facility #281

0 commits merged into from Mar 12, 2011

Conversation

epatters
Copy link
Contributor

In an effort to reduce the size of ConsoleWidget, which has grown to behemoth proportions, I have moved most of the HTML exportation code into a separate file. Specifically, I have:

  • Made HTML exportation work again (I broke it while adding PySide support)
  • Fixed missing spacing in the HTML output. The exported HTML now looks almost identical to what is in the actual widget.
  • Removed the unnecessary check for the rich widget. QPlainTextEdit in fact supports HTML extraction, although this is not well advertised in the documentation.
  • Done some other minor cleanup

@fperez
Copy link
Member

fperez commented Feb 27, 2011

When saving to HTML with inline png images from the Pyside version, I get:

Traceback (most recent call last):
  File "/home/fperez/ipython/ipython/IPython/frontend/qt/rich_text.py", line 115, in export
    title = self.window().windowTitle()
AttributeError: 'HtmlExporter' object has no attribute 'window'

Do you know what this is?

@epatters
Copy link
Contributor Author

I fixed the immediate problem, which I hadn't encountered because my exports weren't failing.

It seems to be working on both PySide and PyQt4; I had to manually raise an exception for this code path to be exercised. This means that there is potentially some other problem behind your error. In any case, now you should be able to see what it is.

@fperez
Copy link
Member

fperez commented Feb 27, 2011

Hi Evan,

now I get this message:

Error exporting HTML to /home/fperez/tmp/junk/ipython2.html
'PySide.QtGui.QImage' object has no attribute 'toPyObject'

but in a popup dialog box whose title is "Error". The saved file is created but with 0 size.

The session only had this in two cells:

#1
plot(rand(100))

#2
for i in range(10):
    print i,

and I requested inline png images. The session had been started with '--pylab inline'. I'm running pyside from trunk, with the most recent commit I have being:

commit c3d180fdc269183cb4f46ee773bb8521f283bff0
Author: Renato Araujo Oliveira Filho 
Date:   Thu Feb 10 14:01:59 2011 -0300

    Created unit test for bug #671.

I'm leaving now for the SIAM conference, so I will likely not be able to do much testing until next weekend, unfortunately, but I'll try.

@epatters
Copy link
Contributor Author

epatters commented Mar 1, 2011

I'm not sure how I missed this, but thanks for your thoroughness Fernando. It should work now.

# Imports
#-----------------------------------------------------------------------------

from __future__ import with_statement
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import isn't necessary anymore: we depend on python >= 2.6, so the with statement is always available to us.

@fperez
Copy link
Member

fperez commented Mar 11, 2011

Very minor fixes (see my comments inline). Once you address those easy ones, merge away. And thanks for the good work!

Sorry for the delayed review, last week's travels did a number on my schedule.

minrk added a commit that referenced this pull request Jul 2, 2011
@ivanistheone
Copy link

Hello,

Is there a way to use the export as HTML + base64 png facilities from a script?

I would like to run the script from the command line, to make it generate
an HTML "report" in the current directory, which I could then view with a browser.

ex script.py:

import ???
print "this is the graph"
p.plot([1,2,3], [22,11,33])

ex usage:

python ./myscript.py

then I see a report.html in that folder...

(I guess what I want is a %run that outputs to HTML)
(if it echos the inputs that would be even cooler ;)

Ivan

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
This pull request was closed.
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

Successfully merging this pull request may close these issues.

None yet

3 participants