def __init__(self, url): self.html = None self.app = QApplication(sys.argv) QWebEngineView.__init__(self) self.loadFinished.connect(self._loadFinished) self.load(QUrl(url)) self.app.exec_()
def __init__(self, url): self.app = QApplication(sys.argv) #QWebEnginePage.__init__(self) QWebEngineView.__init__(self) self.loadFinished.connect(self.on_page_load) self.load(QUrl(url)) self.app.exec_()
def __init__(self): QWebEngineView.__init__(self) self.resize(800, 600) self.show() #增加了<script src="qrc:///qtwebchannel/test.js"></script> self.setHtml(""" <script src="qrc:///qtwebchannel/test.js"></script> <script>function message() { return "Clicked!"; }</script> <h1>QtWebKit + Python sample program</h1> <input type="button" value="Click JavaScript!" onClick="alert('[javascript] ' + message())"/> <input type="button" value="Click Python!" onClick="python.alert('[python] ' + python.message())"/> <br /> <iframe src="http://www.so.com/" width="750" height="500" scrolling="no" frameborder="0" align="center"></iframe> """) self.createTrayIcon() self.trayIcon.show()
def __init__(self, parent): QWebEngineView.__init__(self, parent) self.address = "https://www.pracedru.dk:8888" if debug: self.address = "https://www.pracedru.dk:8889" self.load(QUrl(self.address))
def __init__(self, inspector=False): QWebEngineView.__init__(self) self.__inspector = None self.__contextMenuEvent = self.contextMenuEvent self.set_inspector(inspector)
def __init__(self, window, with_container=True): QWebEngineView.__init__(self) self.window = window # todo fix this accessor if with_container: self._container = WebViewContainer(self) else: self._container = None
def __init__(self, url): self.html = '' self.app = QApplication(sys.argv) QWebEngineView.__init__(self) # 子类构造函数继承父类,这种写法python2和3通用,还可以是super().__init__() self.loadFinished.connect(self._loadFinished) self.load(QUrl(url)) self.app.exec()
def __init__(self): QWebEngineView.__init__(self) # self.load(image) self.setHtml(html) self.setWindowOpacity(0.7) radius = 10.0 path = QtGui.QPainterPath() self.resize(640, 480) path.addRoundedRect(QtCore.QRectF(self.rect()), radius, radius) mask = QtGui.QRegion(path.toFillPolygon().toPolygon()) self.setMask(mask) self.move(QtGui.QCursor.pos()) self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint # | QtCore.Qt.X11BypassWindowManagerHint ) self.setGeometry( QStyle.alignedRect(QtCore.Qt.LeftToRight, QtCore.Qt.AlignCenter, QtCore.QSize(640, 480), qApp.desktop().availableGeometry())) self.setStyleSheet( 'QWebView{background-color: darkgray; border: 5px solid darkgray}') self.grabMouse() self.grabKeyboard() print(self.keyboardGrabber())
def __init__(self, url, *args, **kwargs): QWebEngineView.__init__(self, *args, **kwargs) self._page = QWebEnginePage(get_profile()) self.setPage(self._page) self.load(url) # Shortcut to manually reload self.reload_shortcut = QShortcut('CTRL+R', self) self.reload_shortcut.activated.connect(self.reload) # Check if pages is correctly loaded self.loadFinished.connect(self._load_finished) # Shortcut to close self.quit_shortcut = QShortcut('CTRL+ALT+DELETE', self) self.quit_shortcut.activated.connect(lambda: self.close()) # Stretch the browser policy = QSizePolicy() policy.setVerticalStretch(1) policy.setHorizontalStretch(1) policy.setVerticalPolicy(QSizePolicy.Preferred) policy.setHorizontalPolicy(QSizePolicy.Preferred) self.setSizePolicy(policy)
def __init__(self, html): self.html = None self.app = QApplication([]) QWebEngineView.__init__(self) self.loadFinished.connect(self._loadFinished) self.setHtml(html) # self.load(QUrl(url)) self.app.exec_()
def __init__(self): QWebEngineView.__init__(self) # 사용자정의 Page 사용 self.p = Page(self.page().profile()) self.setPage(self.p) url = QDir().current().filePath("html/QWebEngineView_08_alert.html") url = QUrl.fromLocalFile(url) self.page().setUrl(url)
def __init__(self, parent, url=""): QWebEngineView.__init__(self, parent) self.navigator = parent self.webProfile = QWebEngineProfile(self) self.origineUrl = url self.currentUrl = url self.load(url) self.urlChanged.connect(self.on_urlChanged)
def __init__(self, html): self.html = None self.app = QApplication(sys.argv) QWebEngineView.__init__(self) self.loadFinished.connect(self._loadFinished) self.setHtml(html) while self.html is None: self.app.processEvents(QEventLoop.ExcludeUserInputEvents | QEventLoop.ExcludeSocketNotifiers | QEventLoop.WaitForMoreEvents) self.app.quit()
def __init__(self, display=True): self.app = QApplication([]) QWebEngineView.__init__(self) # self.move(300, 300) self.setWindowTitle(win_title) self.resize(1080, 640) self.page().profile().clearHttpCache() self.html = '' self.setWindowOpacity(0.3)
def __init__(self): self.html = None self.ready = False self.app = QApplication(sys.argv) QWebEngineView.__init__(self) self.timer = QTimer() self.loadFinished.connect(self._loadFinished) self.timer.timeout.connect(self.app.processEvents)
def __init__(self, tab, editorPositionToSourceLineFunc, sourceLineToEditorPositionFunc): QWebEngineView.__init__(self, parent=tab) webPage = ReTextWebEnginePage(self, tab) self.setPage(webPage) self.syncscroll = SyncScroll(webPage, editorPositionToSourceLineFunc, sourceLineToEditorPositionFunc) ReTextWebPreview.__init__(self, tab.editBox)
def __init__(self): QWebEngineView.__init__(self) self.settings().setAttribute( QWebEngineSettings.JavascriptCanOpenWindows, True) self.p = Page() self.setPage(self.p) self.settings().setAttribute(QWebEngineSettings.JavascriptEnabled, True) self.settings().setAttribute( QWebEngineSettings.JavascriptCanOpenWindows, True)
def __init__(self, parent, cp750bridge, args): if args.debug: # Enable remote debugger / "inspector" # Must be set before the parent constructor is called LOGGER.warn( "QTWEBENGINE_REMOTE_DEBUGGING enabled on port http://localhost:%s/. This may be a security issue. Remove '-d/--debug' for production environments." % (QTWEBENGINE_REMOTE_DEBUGGING_PORT)) os.environ[ 'QTWEBENGINE_REMOTE_DEBUGGING'] = QTWEBENGINE_REMOTE_DEBUGGING_PORT QWebEngineView.__init__(self, parent) self.setPage(FrontendWebPage(self, cp750bridge, args))
def __init__(self, url): self.html = None self.app = QApplication(sys.argv) QWebEngineView.__init__(self) self.loadFinished.connect(self._loadFinished) self.load(QUrl(url)) while self.html is None: self.app.processEvents(QEventLoop.ExcludeUserInputEvents | QEventLoop.ExcludeSocketNotifiers | QEventLoop.WaitForMoreEvents) self.app.quit()
def __init__(self, url): QWebEngineView.__init__(self) self.loop = QEventLoop( ) #Queda en un loop hasta que acaba la carga de todas las páginas self.loadFinished.connect(self._loadFinished) self.pages = [] self.page().profile().cookieStore().deleteAllCookies() self.page().profile().setPersistentCookiesPolicy( QWebEngineProfile.NoPersistentCookies) self.load(QUrl(url)) self.loop.exec()
def __init__(self, parent, view): QWebEngineView.__init__(self, parent) self.setVisible(False) if os.environ.get('QTWEBENGINE_REMOTE_DEBUGGING'): self.load( QUrl('http://localhost:' + os.environ['QTWEBENGINE_REMOTE_DEBUGGING'])) else: self.setHtml( 'Web Inspector not available. Please start the application with debugging enabled (-d/--debug).' )
def __init__(self, url): from PyQt5.QtWidgets import QApplication import sys from PyQt5.QtCore import QUrl import lxml.html self.html = '' self.app = QApplication(sys.argv) QWebEngineView.__init__(self) self.loadFinished.connect(self._loadFinished) self.load(QUrl(url)) self.app.exec_()
def __init__(self): QWebEngineView.__init__(self) # Flash 등을 사용하기 위해서 Plugin 사용을 허락 QWebEngineSettings.globalSettings().setAttribute( QWebEngineSettings.PluginsEnabled, True); # 로컬파일 사용시 절대경로만 사용해야 함 url = QDir().current().filePath( "html/QWebEngineView_10_plugin_enabled.html") url = QUrl.fromLocalFile(url) self.setUrl(url)
def __init__(self, url, app, osiris_login): self.html = None self.app = app # QApplication(sys.argv) QWebEngineView.__init__(self) self.loadFinished.connect(self._loadFinished) self.load(QUrl(url)) self.osiris_login = osiris_login # TODO: remove osiris_url dependency osiris_url = r"https://osiris.tue.nl/osiris_student_tueprd/ToonResultaten.do" while self.html is None or self.page().url().toString() != osiris_url or "<title>Working...</title>" in self.html: self.app.processEvents( QEventLoop.ExcludeUserInputEvents | QEventLoop.ExcludeSocketNotifiers | QEventLoop.WaitForMoreEvents)
def __init__(self, parent=None): QWebEngineView.__init__(self, parent) self.setAttribute(Qt.WA_TranslucentBackground) self.setWindowFlags(Qt.FramelessWindowHint) self._page = GraphVisualizePage() self.setPage(self._page) self._channel = QWebChannel(self._page) self._channel.registerObject('page', self._page) self._page.setWebChannel(self._channel) self.loadFinished.connect(self._on_load_finished) self.setUrl(QUrl('qrc:/graph_visualizer/test.html'))
def __init__(self, tab, editorPositionToSourceLineFunc, sourceLineToEditorPositionFunc): QWebEngineView.__init__(self, parent=tab) webPage = ReTextWebEnginePage(self, tab) self.setPage(webPage) self.syncscroll = SyncScroll(webPage, editorPositionToSourceLineFunc, sourceLineToEditorPositionFunc) ReTextWebPreview.__init__(self, tab.editBox) settings = self.settings() settings.setAttribute(QWebEngineSettings.LocalContentCanAccessFileUrls, False)
def __init__(self): QWebEngineView.__init__(self) settings = self.settings() settings.setAttribute(QWebEngineSettings.LocalStorageEnabled, True) settings.setAttribute(QWebEngineSettings.DnsPrefetchEnabled, True) settings.setAttribute(QWebEngineSettings.JavascriptCanOpenWindows, True) settings.setAttribute(QWebEngineSettings.JavascriptCanAccessClipboard, True) settings.setAttribute(QWebEngineSettings.Accelerated2dCanvasEnabled, True) settings.setAttribute(QWebEngineSettings.FullScreenSupportEnabled, True) self.loadFinished.connect(self._on_load_finished)
def __init__(self): QWebEngineView.__init__(self) self.index = 0 self.page().loadFinished.connect(self.loadFinished) self.page().loadProgress.connect(self.loadProgress) self.script = QWebEngineScript() self.script.setInjectionPoint(QWebEngineScript.Deferred) self.script.setRunsOnSubFrames(True) self.urlLogin = QUrl("http://reg.163.com/Logout.jsp?url=http://ecard.163.com/account/query_balance") self.urlVerify = QUrl("http://ecard.163.com/handle_login") self.urlBalance = QUrl("http://ecard.163.com/handle_query_verify") self.queryCallBack = None self.setProgress = None
def __init__(self, *args, **kwargs): """ init runs when a class is called, ever. it is a must to have """ super(Browser, self).__init__(*args, **kwargs) self.web = QWebView.__init__(self) #initialize qwebview self.ui() # run the UI
def __init__(self, argsparsed, dirnameparsed): global args args = argsparsed global dirname dirname = dirnameparsed self.browser = QWebEngineView.__init__(self)
def __init__(self): QWebEngineView.__init__(self) self.config() self.set_trigger() # WebEngine 的 cookie store 没提供获取 cookie 的方法,因此只能通过 cookieAdded 事件捕获。 # 不能用 SimpleCookie, 因为 SimpleCookie 仅以 cookie name 作为 key, 不能存储 name 相同而 domain 不同 # 的 cookie, 后者会覆盖前者, 导致 cookie 丢失. 比如, 京东登录成功后会返回: # pin=***; expires=Fri, 14-Apr-2017 17:29:28 GMT; domain=.jd.com; path=/ # pin=***; expires=Fri, 14-Apr-2017 17:29:28 GMT; domain=.360buy.com; path=/ # 等一系列同名 cookie. self.cookies = RequestsCookieJar() # 当到达 target 时自动关闭浏览器窗口 self.target = None
def __init__(self): QWebEngineView.__init__(self)
def __init__(self, parent=None): QWebEngineView.__init__(self, parent) self.settings = QWebEngineSettings.globalSettings() self.settings.setAttribute(QWebEngineSettings.LocalContentCanAccessFileUrls, True)