當前位置: 首頁>>代碼示例>>Python>>正文


Python QtCore.QUrl方法代碼示例

本文整理匯總了Python中PySide2.QtCore.QUrl方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QUrl方法的具體用法?Python QtCore.QUrl怎麽用?Python QtCore.QUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PySide2.QtCore的用法示例。


在下文中一共展示了QtCore.QUrl方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _open_item_tracker

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QUrl [as 別名]
def _open_item_tracker(self):
        # Importing this at root level seems to crash linux tests :(
        from PySide2.QtWebEngineWidgets import QWebEngineView

        tracker_window = QMainWindow()
        tracker_window.setWindowTitle("Item Tracker")
        tracker_window.resize(370, 380)

        web_view = QWebEngineView(tracker_window)
        tracker_window.setCentralWidget(web_view)

        self.web_view = web_view

        def update_window_icon():
            tracker_window.setWindowIcon(web_view.icon())

        web_view.iconChanged.connect(update_window_icon)
        web_view.load(QUrl("https://spaghettitoastbook.github.io/echoes/tracker/"))

        tracker_window.show()
        self._item_tracker_window = tracker_window

    # Difficulties stuff 
開發者ID:randovania,項目名稱:randovania,代碼行數:25,代碼來源:main_window.py

示例2: __init__

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QUrl [as 別名]
def __init__(self, parent=None):
        super(SlippyMap, self).__init__(parent)

        self._offset = QPoint()
        self._tilesRect = QRect()
        self._tilePixmaps = {}  # Point(x, y) to QPixmap mapping
        self._manager = QNetworkAccessManager()
        self._url = QUrl()
        # public vars
        self.width = 400
        self.height = 300
        self.zoom = 15
        self.latitude = 59.9138204
        self.longitude = 10.7387413

        self._emptyTile = QPixmap(TDIM, TDIM)
        self._emptyTile.fill(Qt.lightGray)

        self.request = QNetworkRequest()
        self.cache = QNetworkDiskCache()
        self.cache.setCacheDirectory(QStandardPaths.writableLocation(QStandardPaths.CacheLocation))
        self._manager.setCache(self.cache)
        self._manager.finished.connect(self.handleNetworkData) 
開發者ID:SanPen,項目名稱:GridCal,代碼行數:25,代碼來源:lightmap.py

示例3: download

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QUrl [as 別名]
def download(self):
        grab = None
        for x in range(self._tilesRect.width()):
            for y in range(self._tilesRect.height()):
                tp = Point(self._tilesRect.topLeft() + QPoint(x, y))
                if tp not in self._tilePixmaps:
                    grab = QPoint(tp)
                    break

        if grab is None:
            self._url = QUrl()
            return

        path = 'http://tile.openstreetmap.org/%d/%d/%d.png' % (self.zoom, grab.x(), grab.y())
        self._url = QUrl(path)
        self.request = QNetworkRequest()
        self.request.setUrl(self._url)
        self.request.setRawHeader(b'User-Agent', b'Nokia (PyQt) Graphics Dojo 1.0')
        self.request.setAttribute(QNetworkRequest.User, grab)
        self._manager.get(self.request) 
開發者ID:SanPen,項目名稱:GridCal,代碼行數:22,代碼來源:lightmap.py

示例4: run_command

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QUrl [as 別名]
def run_command(self, command, **kwargs):
        request = QtNetwork.QNetworkRequest(QtCore.QUrl('http://localhost:7954/'+command))
        request.setHeader(QtNetwork.QNetworkRequest.ContentTypeHeader, "application/x-www-form-urlencoded")
        reply = self.network.post(request, dict_to_post_data(kwargs))
        # reply.finished.connect(cb)
        reply.error.connect(self.on_command_error) 
開發者ID:lbryio,項目名稱:torba,代碼行數:8,代碼來源:application.py

示例5: validate_url

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QUrl [as 別名]
def validate_url(self, url: str) -> None:
    """
    * Check if is a URL or HTML and if is valid
    * :param self: QWebEnginePage
    * :param web_contents: URL or HTML
    """
    if "!doctype" in url.lower():
        # Inject HTML
        base_url = get_current_path()
        self.setHtml(url, QUrl(f"file://{base_url}/"))
        print("Loading local HTML")
    else:
        if url.endswith(".html"):
            # HTML file
            if not url.startswith("/"):
                url = f"/{url}"
            url = f"file://{url}"

        elif "://" not in url:
            # HTML URL
            url = f"https://{url}"

        url = QUrl(url)
        if url.isValid():
            self.load(url)
            print(f"Loading URL:{url.toString()}") 
開發者ID:codesardine,項目名稱:Jade-Application-Kit,代碼行數:28,代碼來源:WebEngine.py

示例6: _on_click

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QUrl [as 別名]
def _on_click(self, url: str, title=""):
        view = Instance.retrieve("view")
        if url.startswith("https"):
            return lambda: view.setUrl(QUrl(url))
        else:
            msg = url
            return lambda: InfoDialog(self, title, msg) 
開發者ID:codesardine,項目名稱:Jade-Application-Kit,代碼行數:9,代碼來源:Widgets.py

示例7: open_version_link

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QUrl [as 別名]
def open_version_link(self):
        if self._current_version_url is None:
            raise RuntimeError("Called open_version_link, but _current_version_url is None")

        QDesktopServices.openUrl(QUrl(self._current_version_url))

    # Options 
開發者ID:randovania,項目名稱:randovania,代碼行數:9,代碼來源:main_window.py

示例8: aboutOsm

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QUrl [as 別名]
def aboutOsm(self):
        QDesktopServices.openUrl(QUrl('http://www.openstreetmap.org')) 
開發者ID:SanPen,項目名稱:GridCal,代碼行數:4,代碼來源:lightmap.py

示例9: acceptNavigationRequest

# 需要導入模塊: from PySide2 import QtCore [as 別名]
# 或者: from PySide2.QtCore import QUrl [as 別名]
def acceptNavigationRequest(self, url, _type, is_main_frame) -> bool:
        """
        * Decide if we navigate to a URL
        * :param url: QtCore.QUrl
        * :param _type: QWebEnginePage.NavigationType
        * :param is_main_frame:bool
        """
        self.url = url.toString()
        self.page = JWebPage(self.profile(), self.view(), self.config)
        # Redirect new tabs to same window
        self.page.urlChanged.connect(self._on_url_changed)

        if self.config['webview']["online"]:
            if _type == QWebEnginePage.WebWindowType.WebBrowserTab:
                if self.config['webview']["urlRules"]:
                    # Check for URL rules on new tabs
                    if self.url.startswith(self.config['webview']["urlRules"]["WebBrowserTab"]):
                        self.open_window(self.url)
                        return False
                    elif check_url_rules("WebBrowserTab", self.url, self.config['webview']["urlRules"]):
                        print(f"Redirecting WebBrowserTab^ to same window")
                        return True
                    else:
                        print(f"Deny WebBrowserTab:{self.url}")
                        # check against WebBrowserWindow list to avoid duplicate dialogs
                        if not check_url_rules("WebBrowserWindow", self.url, self.config['webview']["urlRules"]):
                            self._dialog_open_in_browser()
                        return False
                else:
                    return True

            elif _type == QWebEnginePage.WebBrowserBackgroundTab:
                print(f"WebBrowserBackgroundTab request:{self.url}")
                return True

            elif _type == QWebEnginePage.WebBrowserWindow:
                if self.config['webview']["urlRules"] and self.config['webview']["online"]:
                    # Check URL rules on new windows
                    if check_url_rules("WebBrowserWindow", self.url, self.config['webview']["urlRules"]):
                        print(f"Deny WebBrowserWindow:{self.url}")
                        self._dialog_open_in_browser()
                        return False
                    else:
                        print(f"Allow WebBrowserWindow:{self.url}")
                        return True
                else:
                    return True

            elif _type == QWebEnginePage.WebDialog:
                return True
        return True 
開發者ID:codesardine,項目名稱:Jade-Application-Kit,代碼行數:53,代碼來源:WebEngine.py


注:本文中的PySide2.QtCore.QUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。