def __init__(self, parent, term_url='http://127.0.0.1:8070'): """Webview main constructor.""" WebView.__init__(self, parent) self.parent = parent self.copy_action = create_action(self, _("Copy text"), icon=ima.icon('editcopy'), triggered=self.copy, shortcut='Ctrl+Alt+C') self.paste_action = create_action(self, _("Paste text"), icon=ima.icon('editpaste'), triggered=self.paste, shortcut='Ctrl+Alt+V') self.term_url = QUrl(term_url) self.load(self.term_url) copy_shortcut = QShortcut(QKeySequence("Ctrl+Alt+C"), self, self.copy) copy_shortcut.setContext(Qt.WidgetWithChildrenShortcut) paste_shortcut = QShortcut(QKeySequence("Ctrl+Alt+V"), self, self.paste) paste_shortcut.setContext(Qt.WidgetWithChildrenShortcut) if WEBENGINE: self.document = self.page() else: self.document = self.page().mainFrame() self.initial_y_pos = 0
def __init__(self, parent, term_url='http://127.0.0.1:8070', handler=None): """Webview main constructor.""" WebView.__init__(self, parent) self.parent = parent self.copy_action = create_action(self, _("Copy text"), icon=ima.icon('editcopy'), triggered=self.copy, shortcut='Ctrl+Shift+C') self.paste_action = create_action(self, _("Paste text"), icon=ima.icon('editpaste'), triggered=self.paste, shortcut='Ctrl+Shift+V') if WEBENGINE: self.channel = QWebChannel(self.page()) self.page().setWebChannel(self.channel) self.channel.registerObject('handler', handler) self.term_url = QUrl(term_url) self.load(self.term_url) if WEBENGINE: self.document = self.page() try: self.document.profile().clearHttpCache() except AttributeError: pass else: self.document = self.page().mainFrame() self.initial_y_pos = 0 self.setFocusPolicy(Qt.ClickFocus)