当前位置: 首页>>代码示例>>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;未经允许,请勿转载。