Python qtpy.QtCore.QUrl() Examples
The following are 8
code examples of qtpy.QtCore.QUrl().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
qtpy.QtCore
, or try the search function
.
Example #1
Source File: io.py From Pyslvs-UI with GNU Affero General Public License v3.0 | 5 votes |
def __open_url(self, url: str) -> None: """Use to open link.""" QDesktopServices.openUrl(QUrl(url)) self.showMinimized()
Example #2
Source File: reportsgui.py From spyder-reports with MIT License | 5 votes |
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)
Example #3
Source File: rich_jupyter_widget.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #4
Source File: rich_jupyter_widget.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #5
Source File: download_api.py From conda-manager with MIT License | 5 votes |
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
Example #6
Source File: table.py From conda-manager with MIT License | 5 votes |
def open_url(self, url): """ Open link from action in default operating system browser. """ if url is None: return QDesktopServices.openUrl(QUrl(url))
Example #7
Source File: main_window.py From conda-manager with MIT License | 5 votes |
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)
Example #8
Source File: download_api.py From conda-manager with MIT License | 4 votes |
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)