mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Move Widget.config() c.s. to Misc class, so the Tk class also inherits them.
This commit is contained in:
		
							parent
							
								
									332e14437c
								
							
						
					
					
						commit
						83bd9a9c8c
					
				
					 1 changed files with 30 additions and 31 deletions
				
			
		|  | @ -567,6 +567,36 @@ def _report_exception(self): | |||
| 		exc, val, tb = sys.exc_type, sys.exc_value, sys.exc_traceback | ||||
| 		root = self._root() | ||||
| 		root.report_callback_exception(exc, val, tb) | ||||
| 	# These used to be defined in Widget: | ||||
| 	def config(self, cnf=None, **kw): | ||||
| 		# XXX ought to generalize this so tag_config etc. can use it | ||||
| 		if kw: | ||||
| 			cnf = _cnfmerge((cnf, kw)) | ||||
| 		elif cnf: | ||||
| 			cnf = _cnfmerge(cnf) | ||||
| 		if cnf is None: | ||||
| 			cnf = {} | ||||
| 			for x in self.tk.split( | ||||
| 				self.tk.call(self._w, 'configure')): | ||||
| 				cnf[x[0][1:]] = (x[0][1:],) + x[1:] | ||||
| 			return cnf | ||||
| 		if type(cnf) is StringType: | ||||
| 			x = self.tk.split(self.tk.call( | ||||
| 				self._w, 'configure', '-'+cnf)) | ||||
| 			return (x[0][1:],) + x[1:] | ||||
| 		apply(self.tk.call, (self._w, 'configure') | ||||
| 		      + self._options(cnf)) | ||||
| 	configure = config | ||||
| 	def cget(self, key): | ||||
| 		return self.tk.call(self._w, 'cget', '-' + key) | ||||
| 	__getitem__ = cget | ||||
| 	def __setitem__(self, key, value): | ||||
| 		Widget.config(self, {key: value}) | ||||
| 	def keys(self): | ||||
| 		return map(lambda x: x[0][1:], | ||||
| 			   self.tk.split(self.tk.call(self._w, 'configure'))) | ||||
| 	def __str__(self): | ||||
| 		return self._w | ||||
| 
 | ||||
| class CallWrapper: | ||||
| 	def __init__(self, func, subst, widget): | ||||
|  | @ -710,8 +740,6 @@ def destroy(self): | |||
| 		global _default_root | ||||
| 		if _default_root is self: | ||||
| 			_default_root = None | ||||
| 	def __str__(self): | ||||
| 		return self._w | ||||
| 	def readprofile(self, baseName, className): | ||||
| 		import os | ||||
| 		if os.environ.has_key('HOME'): home = os.environ['HOME'] | ||||
|  | @ -927,35 +955,6 @@ def __init__(self, master, widgetName, cnf={}, kw={}, extra=()): | |||
| 		      (widgetName, self._w) + extra + self._options(cnf)) | ||||
| 		for k, v in classes: | ||||
| 			k.config(self, v) | ||||
| 	def config(self, cnf=None, **kw): | ||||
| 		# XXX ought to generalize this so tag_config etc. can use it | ||||
| 		if kw: | ||||
| 			cnf = _cnfmerge((cnf, kw)) | ||||
| 		elif cnf: | ||||
| 			cnf = _cnfmerge(cnf) | ||||
| 		if cnf is None: | ||||
| 			cnf = {} | ||||
| 			for x in self.tk.split( | ||||
| 				self.tk.call(self._w, 'configure')): | ||||
| 				cnf[x[0][1:]] = (x[0][1:],) + x[1:] | ||||
| 			return cnf | ||||
| 		if type(cnf) is StringType: | ||||
| 			x = self.tk.split(self.tk.call( | ||||
| 				self._w, 'configure', '-'+cnf)) | ||||
| 			return (x[0][1:],) + x[1:] | ||||
| 		apply(self.tk.call, (self._w, 'configure') | ||||
| 		      + self._options(cnf)) | ||||
| 	configure = config | ||||
| 	def cget(self, key): | ||||
| 		return self.tk.call(self._w, 'cget', '-' + key) | ||||
| 	__getitem__ = cget | ||||
| 	def __setitem__(self, key, value): | ||||
| 		Widget.config(self, {key: value}) | ||||
| 	def keys(self): | ||||
| 		return map(lambda x: x[0][1:], | ||||
| 			   self.tk.split(self.tk.call(self._w, 'configure'))) | ||||
| 	def __str__(self): | ||||
| 		return self._w | ||||
| 	def destroy(self): | ||||
| 		for c in self.children.values(): c.destroy() | ||||
| 		if self.master.children.has_key(self._name): | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Guido van Rossum
						Guido van Rossum