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


Python QtCore.QUrl方法代碼示例

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


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

示例1: __open_url

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QUrl [as 別名]
def __open_url(self, url: str) -> None:
        """Use to open link."""
        QDesktopServices.openUrl(QUrl(url))
        self.showMinimized() 
開發者ID:KmolYuan,項目名稱:Pyslvs-UI,代碼行數:6,代碼來源:io.py

示例2: set_html_from_file

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QUrl [as 別名]
def set_html_from_file(self, output_fname, input_fname=None):
        """Set html text from a file."""
        if input_fname is None:
            input_fname = output_fname
        html = ""
        with codecs.open(output_fname, encoding="utf-8") as file:
            html = file.read()

        base_url = QUrl()
        self.set_html(html, input_fname, base_url) 
開發者ID:spyder-ide,項目名稱:spyder-reports,代碼行數:12,代碼來源:reportsgui.py

示例3: _add_image

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QUrl [as 別名]
def _add_image(self, image):
        """ Adds the specified QImage to the document and returns a
            QTextImageFormat that references it.
        """
        document = self._control.document()
        name = str(image.cacheKey())
        document.addResource(QtGui.QTextDocument.ImageResource,
                             QtCore.QUrl(name), image)
        format = QtGui.QTextImageFormat()
        format.setName(name)
        return format 
開發者ID:jupyter,項目名稱:qtconsole,代碼行數:13,代碼來源:rich_jupyter_widget.py

示例4: _get_image

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QUrl [as 別名]
def _get_image(self, name):
        """ Returns the QImage stored as the ImageResource with 'name'.
        """
        document = self._control.document()
        image = document.resource(QtGui.QTextDocument.ImageResource,
                                  QtCore.QUrl(name))
        return image 
開發者ID:jupyter,項目名稱:qtconsole,代碼行數:9,代碼來源:rich_jupyter_widget.py

示例5: download

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QUrl [as 別名]
def download(self, url, path):
        """Download url and save data to path."""
        # original_url = url
#        print(url)
        qurl = QUrl(url)
        url = to_text_string(qurl.toEncoded(), encoding='utf-8')

        logger.debug(str((url, path)))
        if url in self._workers:
            while not self._workers[url].finished:
                return self._workers[url]

        worker = DownloadWorker(url, path)

        # Check download folder exists
        folder = os.path.dirname(os.path.abspath(path))
        if not os.path.isdir(folder):
            os.makedirs(folder)

        request = QNetworkRequest(qurl)
        self._head_requests[url] = request
        self._paths[url] = path
        self._workers[url] = worker
        self._manager.head(request)
        self._timer.start()

        return worker 
開發者ID:spyder-ide,項目名稱:conda-manager,代碼行數:29,代碼來源:download_api.py

示例6: open_url

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QUrl [as 別名]
def open_url(self, url):
        """
        Open link from action in default operating system browser.
        """
        if url is None:
            return
        QDesktopServices.openUrl(QUrl(url)) 
開發者ID:spyder-ide,項目名稱:conda-manager,代碼行數:9,代碼來源:table.py

示例7: report_issue

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QUrl [as 別名]
def report_issue(self):
        if PY3:
            from urllib.parse import quote
        else:
            from urllib import quote     # analysis:ignore

        issue_template = """\
## Description

- *What steps will reproduce the problem?*
1.
2.
3.

- *What is the expected output? What do you see instead?*


- *Please provide any additional information below*


## Version and main components

- Conda Package Manager Version:  {version}
- Conda Version:  {conda version}
- Python Version:  {python version}
- Qt Version    :  {Qt version}
- QtPy Version    :  {QtPy version}
"""
        url = QUrl("https://github.com/spyder-ide/conda-manager/issues/new")
        url.addEncodedQueryItem("body", quote(issue_template))
        QDesktopServices.openUrl(url) 
開發者ID:spyder-ide,項目名稱:conda-manager,代碼行數:33,代碼來源:main_window.py

示例8: _request_finished

# 需要導入模塊: from qtpy import QtCore [as 別名]
# 或者: from qtpy.QtCore import QUrl [as 別名]
def _request_finished(self, reply):
        """Callback for download once the request has finished."""
        url = to_text_string(reply.url().toEncoded(), encoding='utf-8')

        if url in self._paths:
            path = self._paths[url]
        if url in self._workers:
            worker = self._workers[url]

        if url in self._head_requests:
            error = reply.error()
#            print(url, error)
            if error:
                logger.error(str(('Head Reply Error:', error)))
                worker.sig_download_finished.emit(url, path)
                worker.sig_finished.emit(worker, path, error)
                return

            self._head_requests.pop(url)
            start_download = not bool(error)
            header_pairs = reply.rawHeaderPairs()
            headers = {}

            for hp in header_pairs:
                headers[to_text_string(hp[0]).lower()] = to_text_string(hp[1])

            total_size = int(headers.get('content-length', 0))

            # Check if file exists
            if os.path.isfile(path):
                file_size = os.path.getsize(path)

                # Check if existing file matches size of requested file
                start_download = file_size != total_size

            if start_download:
                # File sizes dont match, hence download file
                qurl = QUrl(url)
                request = QNetworkRequest(qurl)
                self._get_requests[url] = request
                reply = self._manager.get(request)

                error = reply.error()
                if error:
                    logger.error(str(('Reply Error:', error)))

                reply.downloadProgress.connect(
                    lambda r, t, w=worker: self._progress(r, t, w))
            else:
                # File sizes match, dont download file or error?
                worker.finished = True
                worker.sig_download_finished.emit(url, path)
                worker.sig_finished.emit(worker, path, None)
        elif url in self._get_requests:
            data = reply.readAll()
            self._save(url, path, data) 
開發者ID:spyder-ide,項目名稱:conda-manager,代碼行數:58,代碼來源:download_api.py


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