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


Python QtGui.QDesktopServices類代碼示例

本文整理匯總了Python中PythonQt.QtGui.QDesktopServices的典型用法代碼示例。如果您正苦於以下問題:Python QDesktopServices類的具體用法?Python QDesktopServices怎麽用?Python QDesktopServices使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: startAuthenticationProcess

	def startAuthenticationProcess(self):
		self.settingsDialog.group_account.widget_authorize.button_authenticate.setEnabled(False)
		self.flow = dropbox.oauth.DropboxOAuth2FlowNoRedirect('sfacmqvdb9dn66r', 'hx8meda636xgsox')
		authorize_url = QUrl(self.flow.start())
		QDesktopServices.openUrl(authorize_url)
		try:
			code = raw_input("Enter the authorization code from the dropbox website:")
		except NameError:
			code = input("Enter the authorization code from the dropbox website:")
		if code:
			try:
				oauth2_result = self.flow.finish(code)
				self.access_token = oauth2_result.access_token
				self.client = dropbox.Dropbox(self.access_token)
				account = self.client.users_get_current_account()
				self.user_id = account.account_id
				self.display_name = account.name.display_name
			except dropbox.auth.AccessError:
				if "win" in sys.platform: #Workaround for crash on windows
					self.parentWidget.hide()
					self.settingsDialog.hide()
				QMessageBox.critical(self.settingsDialog, "Failed to authenticate", "Failed to authenticate with Dropbox. Wrong code?")
				if "win" in sys.platform:
					self.settingsDialog.show()
					self.parentWidget.show()
		self.saveSettings()
		self.updateUi()
開發者ID:olav-st,項目名稱:screencloud-plugins,代碼行數:27,代碼來源:main.py

示例2: SearchFinished

 def SearchFinished():
   data = json.loads(str(reply.readAll()))
   feed = data['feed']
   try:
     print feed['entry'][0]['media$group']['media$player'][0]['url']
     youtube_url = feed['entry'][0]['media$group']['media$player'][0]['url']
     QDesktopServices.openUrl(QUrl.fromEncoded(str(youtube_url)))
   except Exception, e:
     print e
開發者ID:ximion,項目名稱:Clementine-LibDanceTag,代碼行數:9,代碼來源:youtube.py

示例3: startAuthenticationProcess

	def startAuthenticationProcess(self):
		self.saveSettings()
		self.loadSettings()
		self.settingsDialog.group_account.button_authenticate.setEnabled(False)
		self.settingsDialog.group_account.label_code.setEnabled(True)
		self.settingsDialog.group_account.input_code.setEnabled(True)
		self.settingsDialog.group_account.button_code.setEnabled(True)
		auth_url = self.imgur.authorization_url('pin')
		QDesktopServices.openUrl(QUrl(auth_url))
		self.settingsDialog.group_account.button_code.connect("clicked()", self.pinEntered)
開發者ID:Nothing4You,項目名稱:screencloud-plugins,代碼行數:10,代碼來源:main.py

示例4: startAuthenticationProcess

	def startAuthenticationProcess(self):
		self.saveSettings()
		self.loadSettings()
		auth_url = self.imgur.authorization_url('pin')
		QDesktopServices.openUrl(QUrl(auth_url))
		pin = raw_input("Enter PIN from imgur website:")
		if pin:
			try:
				self.access_token, self.refresh_token = self.imgur.exchange_pin(pin)
			except KeyError as e:
				QMessageBox.critical(self.settingsDialog, "Imgur key error", "Failed to exchange pin. " + e.message)
		self.access_token, self.username = self.imgur.refresh_access_token()
		self.saveSettings()
		self.updateUi()
開發者ID:Rocik,項目名稱:screencloud-plugins,代碼行數:14,代碼來源:main.py

示例5: upload

	def upload(self, screenshot, name):
		self.loadSettings()
		#Save to a temporary file
		timestamp = time.time()
		tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
		screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
		#Connect to server
		transport = paramiko.Transport((self.host, self.port))
		if self.authMethod == "Password":
			try:
				transport.connect(username = self.username, password = self.password)
			except paramiko.AuthenticationException:
				ScreenCloud.setError("Authentication failed (password)")
				return False
		else:
			try:
				private_key = paramiko.RSAKey.from_private_key_file(self.keyfile, password=self.passphrase)
				transport.connect(username=self.username, pkey=private_key)
			except paramiko.AuthenticationException:
				ScreenCloud.setError("Authentication failed (key)")
				return False
		sftp = paramiko.SFTPClient.from_transport(transport)
		try:
			sftp.put(tmpFilename, self.folder + "/" + ScreenCloud.formatFilename(name))
		except IOError:
			ScreenCloud.setError("Failed to write " + self.folder + "/" + ScreenCloud.formatFilename(name) + ". Check permissions.")
			return False
		sftp.close()
		transport.close()
		if self.url:
			ScreenCloud.setUrl(self.url + ScreenCloud.formatFilename(name))
		return True
開發者ID:Nothing4You,項目名稱:screencloud-plugins,代碼行數:32,代碼來源:main.py

示例6: upload

	def upload(self, screenshot, name):
		self.loadSettings()
		#Make sure we have a up to date token
		if not self.uploadAnon:
			try:
				self.imgur.refresh_access_token()
			except Exception as e:
				ScreenCloud.setError("Failed to refresh imgur access token. " + e.message)
				return False
		#Save to a temporary file
		timestamp = time.time()
		try:
			tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
		except AttributeError:
			from PythonQt.QtCore import QStandardPaths #fix for Qt5
			tmpFilename = QStandardPaths.writableLocation(QStandardPaths.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
		screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
		#Upload!
		try:
			uploaded_image = self.imgur.upload_image(tmpFilename, title=ScreenCloud.formatFilename(name, False))
		except Exception as e:
			ScreenCloud.setError("Failed to upload to imgur. " + e.message)
			return False
		if self.copyLink:
			if self.copyDirectLink:
				ScreenCloud.setUrl(uploaded_image.link)
			else:
				ScreenCloud.setUrl("https://imgur.com/" + uploaded_image.id)
		return True
開發者ID:SpiderX,項目名稱:screencloud-plugins,代碼行數:29,代碼來源:main.py

示例7: upload

	def upload(self, screenshot, name):
		self.loadSettings()
		try:
			tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + name
		except AttributeError:
			from PythonQt.QtCore import QStandardPaths #fix for Qt5
			tmpFilename = QStandardPaths.writableLocation(QStandardPaths.TempLocation) + "/" + name
		screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
		command = string.Formatter().vformat(self.commandFormat, (), defaultdict(str, s = tmpFilename))
		try:
			command = command.encode(sys.getfilesystemencoding())
		except UnicodeEncodeError:
			ScreenCloud.setError("Invalid characters in command '" + command + "'")
			return False
		try:
			p = subprocess.Popen(command.split())
			p.wait()
			if p.returncode > 0:
				ScreenCloud.setError("Command " + command + " did not return 0")
				return False

		except OSError:
			ScreenCloud.setError("Failed to run command " + command)
			return False
			
		return True
開發者ID:SpiderX,項目名稱:screencloud-plugins,代碼行數:26,代碼來源:main.py

示例8: upload

	def upload(self, screenshot, name):
		self.loadSettings()

		timestamp = time.time()
		tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
		screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())

		ftp = ftplib.FTP()
		ftp.connect(self.host, self.port)
		ftp.login(self.username, self.password)
		f = open(tmpFilename, 'rb')
		try:
			ftp.cwd(self.folder)
		except ftplib.error_perm as err:
			ScreenCloud.setError(err.message)
			return False
		try:
			ftp.storbinary('STOR ' + name, f)
		except ftplib.error_perm as err:
			ScreenCloud.setError(err.message)
			return False
		ftp.quit()
		f.close()
		if self.url:
			ScreenCloud.setUrl(self.url + ScreenCloud.formatFilename(name))
		return True
開發者ID:Rocik,項目名稱:screencloud-plugins,代碼行數:26,代碼來源:main.py

示例9: upload

    def upload(self, screenshot, name):
        self.loadSettings()
        # Save to a temporary file
        timestamp = time.time()
        try:
            tmpFilename = (
                QDesktopServices.storageLocation(QDesktopServices.TempLocation)
                + "/"
                + ScreenCloud.formatFilename(str(timestamp))
            )
        except AttributeError:
            from PythonQt.QtCore import QStandardPaths  # fix for Qt5

            tmpFilename = (
                QStandardPaths.writableLocation(QStandardPaths.TempLocation)
                + "/"
                + ScreenCloud.formatFilename(str(timestamp))
            )
        screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())
        # Connect to server
        try:
            transport = paramiko.Transport((self.host, self.port))
        except Exception as e:
            ScreenCloud.setError(e.message)
            return False
        if self.authMethod == "Password":
            try:
                transport.connect(username=self.username, password=self.password)
            except paramiko.AuthenticationException:
                ScreenCloud.setError("Authentication failed (password)")
                return False
        else:
            try:
                private_key = paramiko.RSAKey.from_private_key_file(self.keyfile, password=self.passphrase)
                transport.connect(username=self.username, pkey=private_key)
            except paramiko.AuthenticationException:
                ScreenCloud.setError("Authentication failed (key)")
                return False
            except paramiko.SSHException as e:
                ScreenCloud.setError("Error while connecting to " + self.host + ":" + str(self.port) + ". " + e.message)
                return False
            except Exception as e:
                ScreenCloud.setError("Unknown error: " + e.message)
                return False
        sftp = paramiko.SFTPClient.from_transport(transport)
        try:
            sftp.put(tmpFilename, self.folder + "/" + ScreenCloud.formatFilename(name))
        except IOError:
            ScreenCloud.setError(
                "Failed to write " + self.folder + "/" + ScreenCloud.formatFilename(name) + ". Check permissions."
            )
            return False
        sftp.close()
        transport.close()
        if self.url:
            ScreenCloud.setUrl(self.url + ScreenCloud.formatFilename(name))
        return True
開發者ID:Ichbinjoe,項目名稱:screencloud-plugins,代碼行數:57,代碼來源:main.py

示例10: browseForKeyfile

 def browseForKeyfile(self):
     filename = QFileDialog.getOpenFileName(
         self.settingsDialog,
         "Select Keyfile...",
         QDesktopServices.storageLocation(QDesktopServices.HomeLocation),
         "*",
     )
     if filename:
         self.settingsDialog.group_server.input_keyfile.setText(filename)
開發者ID:Ichbinjoe,項目名稱:screencloud-plugins,代碼行數:9,代碼來源:main.py

示例11: __init__

	def __init__(self):
		paramiko.util.log_to_file(QDesktopServices.storageLocation(QDesktopServices.HomeLocation) + "/screencloud-sftp.log")
		uil = QUiLoader()
		self.settingsDialog = uil.load(QFile(workingDir + "/settings.ui"))
		self.settingsDialog.group_server.combo_auth.connect("currentIndexChanged(QString)", self.authMethodChanged)
		self.settingsDialog.group_server.button_browse.connect("clicked()", self.browseForKeyfile)
		self.settingsDialog.group_location.input_name.connect("textChanged(QString)", self.nameFormatEdited)
		self.loadSettings()
		self.updateUi()
開發者ID:Nothing4You,項目名稱:screencloud-plugins,代碼行數:9,代碼來源:main.py

示例12: __init__

	def __init__(self):
		try:
			tempLocation = QDesktopServices.storageLocation(QDesktopServices.TempLocation)
		except AttributeError:
			from PythonQt.QtCore import QStandardPaths #fix for Qt5
			tempLocation = QStandardPaths.writableLocation(QStandardPaths.TempLocation)

		paramiko.util.log_to_file(tempLocation + "/screencloud-sftp.log")
		self.uil = QUiLoader()
		self.loadSettings()
開發者ID:SpiderX,項目名稱:screencloud-plugins,代碼行數:10,代碼來源:main.py

示例13: upload

	def upload(self, screenshot, name):
		self.loadSettings()
		timestamp = time.time()
		tmpFilename = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + "/" + ScreenCloud.formatFilename(str(timestamp))
		screenshot.save(QFile(tmpFilename), ScreenCloud.getScreenshotFormat())

		f = open(tmpFilename, 'rb')
		response = self.client.put_file('/' + ScreenCloud.formatFilename(name), f)
		f.close()
		os.remove(tmpFilename)
		if self.copy_link:
			share = self.client.share('/' + ScreenCloud.formatFilename(name))
			ScreenCloud.setUrl(share['url'])

		return True
開發者ID:SilverCory,項目名稱:screencloud-plugins,代碼行數:15,代碼來源:main.py

示例14: upload

    def upload(self, screenshot, name):

        temp = QDesktopServices.storageLocation(QDesktopServices.TempLocation)
        file = temp + '/' + name

        screenshot.save(QFile(file), ScreenCloud.getScreenshotFormat())

        register_openers()

        datagen, headers = multipart_encode({'file': open(file, 'rb')})
        req = urllib2.Request('https://vgy.me:443/upload', datagen, headers)

        res = json.loads(urllib2.urlopen(req).read())

        ScreenCloud.setUrl(res['url'])
        return True
開發者ID:seanc,項目名稱:screencloud-vgy,代碼行數:16,代碼來源:main.py

示例15: upload

    def upload(self, screenshot, name):
        temp = QDesktopServices.storageLocation(QDesktopServices.TempLocation)
        file = temp + '/' + name

        screenshot.save(QFile(file), ScreenCloud.getScreenshotFormat())

        ns = NoelShack()

        try:
            url = ns.upload(file)
        except NoelShackError as e:
            ScreenCloud.setError(str(e))
            return False

        ScreenCloud.setUrl(url)
        return True
開發者ID:gvsurenderreddy,項目名稱:noelshack-screencloud,代碼行數:16,代碼來源:main.py


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