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


Python BtBaseDialog.run方法代碼示例

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


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

示例1: run

# 需要導入模塊: from btsyncutils import BtBaseDialog [as 別名]
# 或者: from btsyncutils.BtBaseDialog import run [as 別名]
	def run(self):
		while True:
			response = BtBaseDialog.run(self)
			if response == Gtk.ResponseType.CANCEL:
				return response
			elif response == Gtk.ResponseType.OK:
				self.secret = self.secret_w.get_text()
				self.folder = self.folder_w.get_text()
				# test if secret is OK
				if self.api.get_error_code(self.api.get_secrets(self.secret)) > 0:
					self.show_warning(
						'This secret is invalid.\nPlease generate a new '\
						'secret or enter your shared folder secret.'
					)
				# test if string is an absolute path and a directory
				elif len(self.folder) == 0 or self.folder[0] != '/' or not os.path.isdir(self.folder):
					self.show_warning('Can\'t open the destination folder.')
				# test if the specified directory is readable and writable
				elif not os.access(self.folder,os.W_OK) or not os.access(self.folder,os.R_OK):
					self.show_warning(
						'Don\'t have permissions to write to the selected folder.'
					)
				# test if the specified data is unique
				elif self.is_duplicate_folder(self.folder,self.secret):
					self.show_warning('Selected folder is already added to BitTorrent Sync.')
				else:
					return response
開發者ID:brianpburns,項目名稱:btsync-deb,代碼行數:29,代碼來源:dialogs.py

示例2: run

# 需要導入模塊: from btsyncutils import BtBaseDialog [as 別名]
# 或者: from btsyncutils.BtBaseDialog import run [as 別名]
	def run(self):
		self.dlg.set_default_response(Gtk.ResponseType.OK)
		while True:
			response = BtBaseDialog.run(self)
			if response == Gtk.ResponseType.CANCEL:
				return response
			elif response == Gtk.ResponseType.DELETE_EVENT:
				return response
			elif response == Gtk.ResponseType.OK:
				if self.changed:
					# read settings
					self.username = self.username_w.get_text()
					self.password = self.password_w.get_text()
					if self.username == '' or self.password == '':
						self.username = None
						self.password = None
					self.portui = self.bindport_w.get_value_as_int() if self.bindportset_w.get_active() else None
					if self.bindlocal_w.get_active():
						self.bindui = None
					elif self.bindall_w.get_active():
						self.bindui = '0.0.0.0'
					# process settings
					self.agent.set_pref('username', self.username, delnone=True)
					self.agent.set_pref('password', self.password, delnone=True)
					self.agent.set_pref('bindui', self.bindui, delnone=True)
					self.agent.set_pref('portui', self.portui, delnone=True)
					# restart the whole game...
					if self.agent.paused:
						self.agent.load_prefs()
						self.agent.read_prefs()
						self.agent.reset_connection_params()
					else:
						self.agent.suspend()
						self.agent.load_prefs()
						self.agent.read_prefs()
						self.agent.reset_connection_params()
						self.agent.resume()
				return response
開發者ID:17Halbe,項目名稱:btsync-deb,代碼行數:40,代碼來源:dialogs.py

示例3: run

# 需要導入模塊: from btsyncutils import BtBaseDialog [as 別名]
# 或者: from btsyncutils.BtBaseDialog import run [as 別名]
	def run(self):
		self.dlg.set_default_response(Gtk.ResponseType.OK)
		while True:
			response = BtBaseDialog.run(self)
			if response == Gtk.ResponseType.CANCEL:
				return response
			elif response == Gtk.ResponseType.DELETE_EVENT:
				return response
			elif response == Gtk.ResponseType.OK:
				self.addr = self.addr_w.get_text()
				self.port = self.port_w.get_text()
				# test if a hostname is specified
				if len(self.addr) == 0:
					self.show_warning(_(
						'A hostname or IP address must be specified'
					))
				# test if port is OK
				elif len(self.port) == 0 or int(self.port) < 1 or int(self.port) > 65534:
					self.show_warning(_(
						'The specified port must be a number between 1 and 65534'
					))
				else:
					return response
開發者ID:Firefishy,項目名稱:btsync-deb,代碼行數:25,代碼來源:dialogs.py


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