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


Python QtCore.QUrl类代码示例

本文整理汇总了Python中PyQt4.QtCore.QUrl的典型用法代码示例。如果您正苦于以下问题:Python QUrl类的具体用法?Python QUrl怎么用?Python QUrl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: showPackage

 def showPackage(self, item):
     row = item.row()
     tmp = self.packageTable.item(row, 1)
     package = tmp.text()
     home = QUrl(self.home)
     curr = QUrl("../../library/%s/html/00Index.html" % package)
     self.htmlViewer.setSource(home.resolved(curr))
开发者ID:wioota,项目名称:ftools-qgis,代码行数:7,代码来源:browsers.py

示例2: downloadFile

    def downloadFile(self):
        url = QUrl(self.url_to_download)

        fileName = QFileDialog.getSaveFileName(self, "Enregistrer la liste des dossiers", self.nameFile, "conf")

        if QFile.exists(fileName):
            QFile.remove(fileName)

        self.outFile = QFile(fileName)
        if not self.outFile.open(QIODevice.WriteOnly):
            QMessageBox.information(self, 'Erreur','Impossible d\'enregistrer le fichier %s: %s.' % (fileName, self.outFile.errorString()))
            self.outFile = None
            return

        #Création que la connexion HTTPS
        mode = QHttp.ConnectionModeHttps
        port = 0
        self.http.setHost(url.host(), mode, port)
        
        self.requeteHTTPannule = False
        path = QUrl.toPercentEncoding(url.path(), "!$&'()*+,;=:@/")
        if path:
            path = str(path)
        else:
            path = '/'

        #Concaténation des paramètres à l'URL
        path = path+("?")
        for item in url.queryItems():
            path = path + item[0] + "=" + item[1] + "&" 
        
        self.http.setUser(self.login, self.password)
        self.httpGetId = self.http.get(path, self.outFile)
开发者ID:Gustry,项目名称:GeoFoncier-consultation,代码行数:33,代码来源:Saver.py

示例3: setUpClass

    def setUpClass(cls):
        """Run before all tests"""
        # Create test layer
        srcpath = os.path.join(TEST_DATA_DIR, 'provider')
        cls.basetestfile = os.path.join(srcpath, 'delimited_wkt.csv')

        url = QUrl.fromLocalFile(cls.basetestfile)
        url.addQueryItem("crs", "epsg:4326")
        url.addQueryItem("type", "csv")
        url.addQueryItem("wktField", "wkt")
        url.addQueryItem("spatialIndex", "no")
        url.addQueryItem("subsetIndex", "no")
        url.addQueryItem("watchFile", "no")

        cls.vl = QgsVectorLayer(url.toString(), u'test', u'delimitedtext')
        assert cls.vl.isValid(), "{} is invalid".format(cls.basetestfile)
        cls.provider = cls.vl.dataProvider()

        cls.basetestpolyfile = os.path.join(srcpath, 'delimited_wkt_poly.csv')

        url = QUrl.fromLocalFile(cls.basetestpolyfile)
        url.addQueryItem("crs", "epsg:4326")
        url.addQueryItem("type", "csv")
        url.addQueryItem("wktField", "wkt")
        url.addQueryItem("spatialIndex", "no")
        url.addQueryItem("subsetIndex", "no")
        url.addQueryItem("watchFile", "no")

        cls.vl_poly = QgsVectorLayer(url.toString(), u'test_polygon', u'delimitedtext')
        assert cls.vl_poly.isValid(), "{} is invalid".format(cls.basetestpolyfile)
        cls.poly_provider = cls.vl_poly.dataProvider()
开发者ID:Naisha634,项目名称:QGIS,代码行数:31,代码来源:test_qgsdelimitedtextprovider.py

示例4: from_user_input

	def from_user_input(userInput):
		# Toma una URL en string y la transforma a un QUrl bien formado
		userInput = QString(userInput)
		
		trimmedString = userInput.trimmed()

		url = QUrl.fromEncoded(trimmedString.toUtf8(), QUrl.TolerantMode)
		urlPrepended = QUrl.fromEncoded((QLatin1String("http://") + trimmedString).toUtf8(), QUrl.TolerantMode)
	
		# Check the most common case of a valid url with scheme and host
		# We check if the port would be valid by adding the scheme to handle the case host:port
		# where the host would be interpretted as the scheme
		if (url.isValid()
			and not url.scheme().isEmpty()
			and (not url.host().isEmpty() or not url.path().isEmpty())
			and urlPrepended.port() == -1):
			return url
	
		# Else, try the prepended one and adjust the scheme from the host name
		if (urlPrepended.isValid() and (not urlPrepended.host().isEmpty() or not urlPrepended.path().isEmpty())):
			dotIndex = trimmedString.indexOf(".")
			hostscheme = trimmedString.left(dotIndex).toLower()
			if (hostscheme == QLatin1String("ftp")):
				urlPrepended.setScheme(QLatin1String("ftp"))
			return urlPrepended
	
		return QUrl() 
开发者ID:igui,项目名称:sdf-showcase,代码行数:27,代码来源:url_helper.py

示例5: load

 def load(self, url=None, encoding=None, keepUndo=False):
     """Load the specified or current url (if None was specified).
     
     Currently only local files are supported. An IOError is raised
     when trying to load a nonlocal URL.
     
     If loading succeeds and an url was specified, the url is make the
     current url (by calling setUrl() internally).
     
     If keepUndo is True, the loading can be undone (with Ctrl-Z).
     
     """
     if url is None:
         url = QUrl()
     u = url if not url.isEmpty() else self.url()
     text = self.load_data(u, encoding or self._encoding)
     if keepUndo:
         c = QTextCursor(self)
         c.select(QTextCursor.Document)
         c.insertText(text)
     else:
         self.setPlainText(text)
     self.setModified(False)
     if not url.isEmpty():
         self.setUrl(url)
     self.loaded()
     app.documentLoaded(self)
开发者ID:mamoch,项目名称:frescobaldi,代码行数:27,代码来源:document.py

示例6: __getReply

 def __getReply(self, params):
     url = QUrl('http://ws.audioscrobbler.com/2.0/')
     url.addQueryItem('api_key', self.__last_fm_key)
     for key, value in params.iteritems():
         url.addQueryItem(key, value)
     request = QNetworkRequest(url)
     return self.__networkManager.get(request)
开发者ID:duganchen,项目名称:lasttagger,代码行数:7,代码来源:lasttagger.py

示例7: downloadFile

    def downloadFile(self, url, archivo_destino):
        url = QUrl(url)
        fileName = archivo_destino
        directorio_usuario_para_pilas = os.path.dirname(archivo_destino)

        if not os.path.exists(directorio_usuario_para_pilas):
            os.mkdir(directorio_usuario_para_pilas)

        if QFile.exists(fileName):
            QFile.remove(fileName)

        self.outFile = QFile(fileName)

        if not self.outFile.open(QIODevice.WriteOnly):
            QMessageBox.information(self, 'Error', 'Lo siento, no se puede descargar el archivo desde %s: %s.' % (self.url, self.outFile.errorString()))
            self.outFile = None
            return

        mode = QHttp.ConnectionModeHttp
        port = url.port()
        if port == -1:
            port = 0
        self.http.setHost(url.host(), mode, port)
        self.httpRequestAborted = False

        path = QUrl.toPercentEncoding(url.path(), "!$&'()*+,;=:@/")
        if path:
            path = str(path)
        else:
            path = '/'

        self.httpGetId = self.http.get(path, self.outFile)
开发者ID:DanKaLeo,项目名称:pilas,代码行数:32,代码来源:descargar.py

示例8: command

 def command(self, command):
     """Perform one command."""
     command = command.split()
     cmd = command[0]
     args = command[1:]
     
     win = QApplication.activeWindow()
     if win not in app.windows:
         if not app.windows:
             import mainwindow
             mainwindow.MainWindow().show()
         win = app.windows[0]
     
     if cmd == b'open':
         url = QUrl.fromEncoded(args[0])
         win.openUrl(url, self.encoding)
     elif cmd == b'encoding':
         self.encoding = str(args[0])
     elif cmd == b'activate_window':
         win.activateWindow()
         win.raise_()
     elif cmd == b'set_current':
         url = QUrl.fromEncoded(args[0])
         win.setCurrentDocument(app.openUrl(url, self.encoding))
     elif cmd == b'set_cursor':
         line, column = map(int, args)
         cursor = win.textCursor()
         pos = cursor.document().findBlockByNumber(line - 1).position() + column
         cursor.setPosition(pos)
         win.currentView().setTextCursor(cursor)
     elif cmd == b'bye':
         self.close()
开发者ID:arnaldorusso,项目名称:frescobaldi,代码行数:32,代码来源:api.py

示例9: DownloadFtp

class DownloadFtp(Download):
    def __init__(self, file_share, local_path, date):
        Download.__init__(self, file_share, local_path, date)
        self.ftp = QFtp(self)
        self.ftp.dataTransferProgress.connect(self.update_progress)
        self.ftp.done.connect(self.download_finished)
        self.ftp.stateChanged.connect(self.state_changed)
        self.url = QUrl(self._file_share.url)
        self.out_file = QFile(self.local_path)

        self.read_bytes = self.out_file.size() 
 
    def start_download(self):
        self.ftp.connectToHost(self.url.host(), self.url.port(21))
        self.ftp.login()
        
        if self.out_file.open(QIODevice.WriteOnly):
            self.ftp.get(self.url.path(), self.out_file)

    def stop(self):
        self.ftp

    def state_changed(self, state):
        if state == 1 or state == 2:
            self._state = 1

    def download_finished(self, _):
        print "finished !"

    def update_progress(self, read_bytes, total_bytes):
        self.read_bytes = read_bytes
开发者ID:Jerk31,项目名称:pyrex,代码行数:31,代码来源:downloads.py

示例10: save

 def save(self, url=None, encoding=None):
     """Saves the document to the specified or current url.
     
     Currently only local files are supported. An IOError is raised
     when trying to save a nonlocal URL.
     
     If saving succeeds and an url was specified, the url is made the
     current url (by calling setUrl() internally).
     
     """
     if url is None:
         url = QUrl()
     u = url if not url.isEmpty() else self.url()
     filename = u.toLocalFile()
     # currently, we do not support non-local files
     if not filename:
         raise IOError("not a local file")
     # keep the url if specified when we didn't have one, even if saving
     # would fail
     if self.url().isEmpty() and not url.isEmpty():
         self.setUrl(url)
     with app.documentSaving(self):
         with open(filename, "wb") as f:
             f.write(self.encodedText())
             f.flush()
             os.fsync(f.fileno())
         self.setModified(False)
         if not url.isEmpty():
             self.setUrl(url)
     self.saved()
     app.documentSaved(self)
开发者ID:mamoch,项目名称:frescobaldi,代码行数:31,代码来源:document.py

示例11: setup

 def setup(self, parent=None, caption=str("Sélectionnez")) :
     self.setFileMode(self.ExistingFiles)
     icon = QtGui.QIcon()
     icon.addPixmap(QtGui.QPixmap(_fromUtf8("resources/PL128.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
     self.setWindowIcon(icon)
     mydir = str(os.environ['USERPROFILE'])
     thedir = QDir("C:/")
     self.setDirectory(thedir)
     url = []
     url.append(QUrl.fromLocalFile(QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation)))
     url.append(QUrl.fromLocalFile(QDesktopServices.storageLocation(QDesktopServices.DesktopLocation)))
     url.append(QUrl.fromLocalFile(QDesktopServices.storageLocation(QDesktopServices.HomeLocation)))
     url.append(QUrl('file:'))
     self.setSidebarUrls(url)
     # self.setDirectory(mydir)
     self.setWindowModality(QtCore.Qt.ApplicationModal)
     MyFileDialog.setNameFilter(self, "Epub (*.epub)")
     self.setLabelText(self.LookIn, "Regarder dans :")
     self.setLabelText(self.FileName, "Fichier")
     self.setLabelText(self.FileType, "Type de fichier")
     self.setLabelText(self.Accept, "Ouvrir")
     self.setLabelText(self.Reject, "Annuler")
     self.setWindowTitle("Sélectionnez un ou plusieurs fichiers")
     self.setOption(self.DontUseNativeDialog, False)
     # self.setOption(self.DontResolveSymlinks, True)
     self.setOption(self.ShowDirsOnly, False)
     self.tree = self.findChild(QtGui.QTreeView)
     self.init_ui()
     self.filesSelected.connect(self.cur_change)
     self.filesSelected.connect(self.choose_file)
开发者ID:vdfebook,项目名称:PersonnaLiseur,代码行数:30,代码来源:dialogue.py

示例12: createRequest

    def createRequest(self, op, req, data):
        #print "createRequest: req.url()", req.url()

        if req.url().host() != "webodf":
            return super(WebODFNetworkManager, self).createRequest(op, req, data);

        path = QUrl("http://webodf/").resolved(req.url()).path()

        print "Request for", path

        if op == QNetworkAccessManager.GetOperation:
            reply = None;
            if path.startswith("/dijit"):
                path = "/wodo" + path # TODO: why gets wodo/ lost?
            resourcePath = Resources.get("documentsharing"+path)
            if os.path.exists(resourcePath):
                print "reply for resource:", resourcePath
                reply = ResourceReply(resourcePath, self)
            elif path == self.genesisDocumentPath:
                print "reply for genesis document:", self.genesisDocumentPath
                reply = ResourceReply(self.genesisDocumentPath, self)
            else:
                avatarUrl = self.sessionBackend.resolveAvatarUrl(path)
                if avatarUrl != "":
                    print "reply for avatar url:", avatarUrl
                    reply = ResourceReply(avatarUrl, self)

            if reply is not None:
                return  reply

            print "Request for unknown resource:", path

        return super(WebODFNetworkManager, self).createRequest(op, req, data)
开发者ID:kogmbh,项目名称:blink-qt,代码行数:33,代码来源:webodfwidget.py

示例13: email

def email(subject, body):
    """Opens the e-mail composer with the given subject and body, with version information added to it."""
    subject = "[{0} {1}] {2}".format(appinfo.appname, appinfo.version, subject)
    body = "{0}\n\n{1}\n\n".format(debuginfo.version_info_string(' -- '), body)
    url = QUrl("mailto:" + appinfo.maintainer_email)
    url.addQueryItem("subject", subject)
    url.addQueryItem("body", body)
    helpers.openUrl(url, "email")
开发者ID:EdwardBetts,项目名称:frescobaldi,代码行数:8,代码来源:bugreport.py

示例14: load_account_page

 def load_account_page(self, account, tab=None, task=None):
     self.tab = tab
     self.task = task
     self.account = account
     url = QUrl(account.server.settings_url)
     for name, value in self.query_items:
         url.addQueryItem(name, value)
     self.load(url)
开发者ID:grengojbo,项目名称:sipclients,代码行数:8,代码来源:accounts.py

示例15: test_rowid

 def test_rowid(self):
     source = QUrl.toPercentEncoding(os.path.join(self.testDataDir, "france_parts.shp"))
     query = QUrl.toPercentEncoding("select rowid as uid, * from vtab limit 1 offset 3")
     l = QgsVectorLayer("?layer=ogr:%s:vtab&query=%s" % (source, query), "vtab2", "virtual", False)
     # the last line must have a fixed rowid (not an autoincrement)
     for f in l.getFeatures():
         lid = f.attributes()[0]
     self.assertEqual(lid, 3)
开发者ID:dudds6699,项目名称:QGIS,代码行数:8,代码来源:test_provider_virtual.py


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