当前位置: 首页>>代码示例>>Python>>正文


Python QWebEngineView.setUrl方法代码示例

本文整理汇总了Python中PyQt5.QtWebEngineWidgets.QWebEngineView.setUrl方法的典型用法代码示例。如果您正苦于以下问题:Python QWebEngineView.setUrl方法的具体用法?Python QWebEngineView.setUrl怎么用?Python QWebEngineView.setUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWebEngineWidgets.QWebEngineView的用法示例。


在下文中一共展示了QWebEngineView.setUrl方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Window

# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import setUrl [as 别名]
class Window(BaseWindow):
    def __init__(self):
        self.debug=1
        self.app = QApplication(sys.argv)
        self.desktop= QApplication.desktop()
        self.web = QWebEngineView()
        self.icon = QIcon(ICON)
        #self.web.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
      
        self.web.titleChanged.connect(self.title_changed)
        self.web.iconUrlChanged.connect(self.icon_changed)
        self.web.page().windowCloseRequested.connect(self.close_window)
        self.web.page().geometryChangeRequested.connect(self.set_geometry)
    
    def show(self,window_state):
        if window_state == "maximized" and not self.web.isMaximized():
            self.web.showNormal()
            self.web.showMaximized()
        elif window_state == "fullscreen" and not self.web.isFullScreen():
            self.web.showNormal()
            self.web.showFullScreen()
        elif window_state == "normal":
            self.web.showNormal()
        else:
            self.web.show()

    def run(self):
        return self.app.exec_()
                
    def set_debug(self, debuglevel):
        self.debug=debuglevel
    
    def set_geometry(self,geom ):
        self.web.setGeometry(geom)
        
    def close_window(self):
        sys.exit()
    
    def icon_changed(self):
        if not self.icon.isNull():
            self.web.setWindowIcon(self.icon)
            
    def title_changed(self, title):
        self.web.setWindowTitle(title)

    def load_url(self,url):
        self.url=QUrl.fromEncoded(url)
        self.web.setUrl(self.url)
    
    def set_size(self,width, height):
        if width<=0:
            width=640
        if height<=0:
            height=480
        
        left=(self.desktop.width()-width)/2
        top=(self.desktop.height()-height)/2
        
        self.web.setGeometry(left,top,width,height)
开发者ID:cris-b,项目名称:oma-welcome,代码行数:61,代码来源:qt5.py

示例2: run

# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import setUrl [as 别名]
 def run(self):
     view = QWebEngineView()
     view.show()
     view.setUrl(QUrl("https://google.com"))
     self.app.exec()
开发者ID:pavanshahm,项目名称:showdownbot,代码行数:7,代码来源:Interface.py

示例3: __init__

# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import setUrl [as 别名]
class FeedlyClient:

    """
    This is a simple client for feedly powered by PyQt5.
    """

    def __init__(self):
        super().__init__()

    # Used by obtain_code
    def parse_code(self):
        if oauth2_redirect in self.engine.url().toString():
            self.webview.close()
            parse = parse_qs(urlparse(self.engine.url().toString()).query)
            self.code = parse["code"]
            self.app.exit()

    def obtain_code(self, url=SandBoxURL, state=""):
        """Obtain an application code

        :param url: A Base url for requests, optional
        :param state: Additional if to be returned, optional
        """
        self.app = QApplication([])

        payload = {
            "response_type": "code",
            "client_id": client_id,
            "redirect_uri": oauth2_redirect,
            "scope": scope,
            "state": state,
        }

        res = requests.get(url + "/v3/auth/auth", params=payload, headers=headers)

        self.webview = QMainWindow()

        self.engine = QWebEngineView()
        self.engine.setUrl(QUrl(res.url))
        self.engine.urlChanged.connect(self.parse_code)

        self.webview.setCentralWidget(self.engine)
        self.webview.show()
        self.app.exec_()

    def get_access_token(self, url=SandBoxURL, state=""):
        """Obtain an access token

        :param url: A Base url for requests, optional
        :param state: Additional if to be returned, optional
        """

        payload = {
            "code": self.code,
            "client_id": client_id,
            "client_secret": client_secret,
            "redirect_uri": oauth2_redirect,
            "state": state,
            "grant_type": "authorization_code",
        }

        res = requests.post(url + "/v3/auth/token", params=payload, headers=headers).json()

        self.refresh_token = res["refresh_token"]
        self.id = res["id"]
        self.plan = res["plan"]
        self.state = res["state"]
        self.token_type = res["token_type"]
        self.access_token = res["access_token"]
        self.expires_in = res["expires_in"]

    def get_refresh_token(self, url=SandBoxURL, state=""):
        """Obtain an application code

        :param url: A Base url for requests, optional
        :param state: Additional if to be returned, optional
        """

        payload = {
            "refresh_token": self.refresh_token,
            "client_id": client_id,
            "client_secret": client_secret,
            "grant_type": "refresh_token",
        }

        res = requests.post(url + "/v3/auth/token", params=payload, headers=headers).json()

        self.id = res["id"]
        self.access_token = res["access_token"]
        self.expires_in = res["expires_in"]
        self.token_type = res["token_type"]
        self.plan = res["plan"]

    def revoke_refresh_token(self, url=SandBoxURL):
        """
        Logout, Refresh token will no longer be valid

        :param url: A Base url for requests, optional
        """

#.........这里部分代码省略.........
开发者ID:TylorS,项目名称:refeed,代码行数:103,代码来源:qt.py

示例4: QApplication

# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import setUrl [as 别名]
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl
import sys

app = QApplication(sys.argv)
view=QWebEngineView()
view.setUrl(QUrl("https://www.baidu.com/"))
view.show()
app.exec_()
开发者ID:IsaiahKing,项目名称:MiscRecord,代码行数:12,代码来源:webengine.py

示例5: QApplication

# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import setUrl [as 别名]
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import os
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtCore import QUrl

app = QApplication([])
view = QWebEngineView()

# view.load(QUrl("http://www.baidu.com"))  # ok

# view.setUrl(QUrl(r"D:\MX_bk\python\测试QtWebKit\test.htm"))  # ok

# view.setUrl(QUrl(r"D:\MX_bk\python\测试QtWebKit\test_noJS.htm"))  # ok

# ok
path = os.getcwd()
url = path + '\\test.htm'
view.setUrl(QUrl(url))

view.show()
app.exec_()
开发者ID:fiso0,项目名称:MxPython,代码行数:26,代码来源:simpleTest.py


注:本文中的PyQt5.QtWebEngineWidgets.QWebEngineView.setUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。