'Error when browsing google earth using homemade browser

I used Python+pyqt+QWebEngineView to write a simple browser, but when I browse google earth, it shows Aw snap!, what is the reason? How can I improve it?

enter image description here

I used Python+pyqt+QWebEngineView to write a simple browser, but when I browse google earth, it shows Aw snap!, what is the reason? How can I improve it?

    import sys
    from PyQt5.QtWidgets import *
    from PyQt5.QtCore import *
    from PyQt5.QtGui import *
    from PyQt5.QtWebEngineWidgets import QWebEngineView
    import webbrowser as web

    class web_window(QMainWindow):
      def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.setWindowTitle('web window')
        self.resize(1300, 700)
        # self.show()

        self.tabWidget = QTabWidget()
        self.tabWidget.setTabShape(QTabWidget.Triangular)
        self.tabWidget.setDocumentMode(True)
        self.tabWidget.setMovable(True)
        self.tabWidget.setTabsClosable(True)
        self.tabWidget.tabCloseRequested.connect(self.close_Tab)
        self.setCentralWidget(self.tabWidget)

        self.webview = WebEngineView(self)
        self.webview.load(QUrl("http://www.google.com"))
        self.create_tab(self.webview)

        navigation_bar = QToolBar('Navigation')

        navigation_bar.setIconSize(QSize(16, 16))

        self.addToolBar(navigation_bar)

        back_button = QAction(QIcon('icons/houtui.png'), 'Back', self)
        next_button = QAction(QIcon('icons/qianjin.png'), 'Forward', self)
        stop_button = QAction(QIcon('icons/close.png'), 'stop', self)
        reload_button = QAction(QIcon('icons/shuaxin.png'), 'reload', self)

        back_button.triggered.connect(self.webview.back)
        next_button.triggered.connect(self.webview.forward)
        stop_button.triggered.connect(self.webview.stop)
        reload_button.triggered.connect(self.webview.reload)

        navigation_bar.addAction(back_button)
        navigation_bar.addAction(next_button)
        navigation_bar.addAction(stop_button)
        navigation_bar.addAction(reload_button)

        self.urlbar = QLineEdit()
        self.urlbar.returnPressed.connect(self.navigate_to_url)

        navigation_bar.addSeparator()
        navigation_bar.addWidget(self.urlbar)

        self.webview.urlChanged.connect(self.renew_urlbar)

    def navigate_to_url(self):
        q = QUrl(self.urlbar.text())
        if q.scheme() == '':
            q.setScheme('http')
        self.webview.setUrl(q)

    def renew_urlbar(self, q):

        self.urlbar.setText(q.toString())
        self.urlbar.setCursorPosition(0)

    def create_tab(self, webview):
        self.tab = QWidget()
        self.tabWidget.addTab(self.tab, "New tab")
        self.tabWidget.setCurrentWidget(self.tab)

        self.Layout = QHBoxLayout(self.tab)
        self.Layout.setContentsMargins(0, 0, 0, 0)
        self.Layout.addWidget(webview)

    def close_Tab(self, index):
        if self.tabWidget.count() > 1:
            self.tabWidget.removeTab(index)
        else:
            self.close()


    class WebEngineView(QWebEngineView):

    def __init__(self, mainwindow, parent=None):
        super(WebEngineView, self).__init__(parent)
        self.mainwindow = mainwindow

    def createWindow(self, QWebEnginePage_WebWindowType):
        new_webview = WebEngineView(self.mainwindow)
        self.mainwindow.create_tab(new_webview)
        return new_webview


if __name__ == "__main__":
    app = QApplication(sys.argv)
    browser = web_window()
    browser.show()
    sys.exit(app.exec_())


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source