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 :
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
PyQt6 Crash Course — a new tutorial in your Inbox every day
Beginner-focused crash course explaining the basics with hands-on examples.
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.