Issue exporting data with Pycharm

Heads up! You've already completed this tutorial.

Eolinwen | 2020-05-12 16:05:07 UTC | #1

Hi Martin.

Even I don't plan to use a QWebView, I have done the MoosAche tutorial. I have found it very interesting and instructive as indeed all the tutorials of LearnPyqt. Great idea.

I'm running in Linux, Manjaro, Desktop environment Cinnamon with the last Python and Qt version i.e 3.82 and 5.14.2

However, I run into an issue when I run it in Pycharm, in a console or even in QtCreator. This behavior comes when I want to save a page with the corresponding function (save page). Here the corresponding code :

python
    def save_file(self):
    filename, _ = QFileDialog.getSaveFileName(self, "Save Page as", "", "Hypertext Markup Languague (*.htm *.html);;" "Allfiles (*.*)")

    if filename:
        html = self.browser.page().toHtml()
        with open(filename, 'w') as file:
            file.write(html)

I get this error :

Python 3.8.2 (default, Apr 8 2020, 14:31:25) Type 'copyright', 'credits' or 'license' for more information IPython 7.14.0 -- An enhanced Interactive Python. Type '?' for help. PyDev console: using IPython 7.14.0 Python 3.8.2 (default, Apr 8 2020, 14:31:25) [GCC 9.3.0] on linux runfile('/home/olivier/Programmation/Apprentissage Programmation/ApprentissagePyQt/Apprentissage_livre_Create_simple_Gui/appli_qtcreator/NavigateurWebBasic/mooseache/main.py', wdir='/home/olivier/Programmation/Apprentissage Programmation/ApprentissagePyQt/Apprentissage_livre_Create_simple_Gui/appli_qtcreator/NavigateurWebBasic/mooseache') Traceback (most recent call last): File "/home/olivier/Programmation/Apprentissage Programmation/ApprentissagePyQt/Apprentissage_livre_Create_simple_Gui/appli_qtcreator/NavigateurWebBasic/mooseache/main.py", line 126, in save_file html = self.browser.page().toHtml() TypeError: toHtml(self, Callable[[str], None]): not enough arguments Process finished with exit code 0

PyQt/PySide 1:1 Coaching with Martin Fitzpatrick — Get one on one help with your Python GUI projects. Working together with you I'll identify issues and suggest fixes, from bugs and usability to architecture and maintainability.

Book Now 60 mins ($195)

I have search in Qt documentation but it has not been a succes. Where is the problem ? I have resolved two issues (coming from me) but not this one. An idea ? Thanks by Advance.

Packaging Python Applications with PyInstaller by Martin Fitzpatrick — This step-by-step guide walks you through packaging your own Python applications from simple examples to complete installers and signed executables.

More info Get the book

A great and wonderful idea this forum.

Over 10,000 developers have bought Create GUI Applications with Python & Qt!
Create GUI Applications with Python & Qt6
Take a look

Downloadable ebook (PDF, ePub) & Complete Source code

Also available from Leanpub and Amazon Paperback

[[ discount.discount_pc ]]% OFF for the next [[ discount.duration ]] [[discount.description ]] with the code [[ discount.coupon_code ]]

Purchasing Power Parity

Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]


Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak
Martin Fitzpatrick

Issue exporting data with Pycharm was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt. Martin founded PythonGUIs to provide easy to follow GUI programming tutorials to the Python community. He has written a number of popular https://www.martinfitzpatrick.com/browse/books/ on the subject.