-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
AttributeError: 'QWebEngineView' object has no attribute 'print_' #1
Comments
Traceback (most recent call last):
File "browser_tabbed.py", line 217, in print_page
dlg.paintRequested.connect(self.browser.print_)
AttributeError: 'MainWindow' object has no attribute 'browser' |
I get the same error as above. The error show up in the console log when the user selects the File submenu "File... Print..." 0-MyProjects/PyQt5-15mins-apps/browser_tabbed') File "C:\Users...!0-MyProjects\PyQt5-15mins-apps\browser_tabbed\browser_tabbed-RSL-WIP.py", line 226, in print_page AttributeError: 'MainWindow' object has no attribute 'browser Should this Why is it using the Please suggest a fix for this, and clarify the fix with an explanation? Thank you. Richard |
@richdevboston You can fix this by adding the method below into the def handle_paint_request(self, printer):
painter = QPainter(printer)
browser = self.tabs.currentWidget()
painter.setViewport(browser.rect())
painter.setWindow(browser.rect())
browser.render(painter)
painter.end() And change the def print_page(self):
dlg = QPrintPreviewDialog()
- dlg.paintRequested.connect(self.browser.print_)
+ dlg.paintRequested.connect(self.handle_paint_request)
dlg.exec_() FYI, these links below can help you if something wrong: To fix def handle_paint_request(self, printer):
painter = QPainter(printer)
- browser = self.tabs.currentWidget()
- painter.setViewport(browser.rect())
- painter.setWindow(browser.rect())
- browser.render(painter)
+ painter.setViewport(self.browser.rect())
+ painter.setWindow(self.browser.rect())
+ self.browser.render(painter)
painter.end() HTH |
https://github.com/mfitzp/15-minute-apps/blob/b99eb330310fe7302ead39473ef0d34cccb3d12d/browser/browser.py#L168
OS: win10 x64
Python: 3.5.4 x64
PyQt: 5.10.0
The text was updated successfully, but these errors were encountered: