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

Create GUI Applications with Python & Qt5 by Martin Fitzpatrick — (PyQt5 Edition) The hands-on guide to making apps with Python — Over 10,000 copies sold!

More info Get the book

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.

A great and wonderful idea this forum.


The complete guide to packaging Python GUI applications with PyInstaller.
[[ 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

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.