mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	 30f2080475
			
		
	
	
		30f2080475
		
	
	
	
	
		
			
			4-char codes. The table which maps codes to datatypes is still pretty empty, I'll fill it as I need entries (or maybe someone wants to spend a nice day filling it?).
		
			
				
	
	
		
			32 lines
		
	
	
	
		
			925 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
	
		
			925 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| # Accessor functions for control properties
 | |
| 
 | |
| from Controls import *
 | |
| import struct
 | |
| 
 | |
| _codingdict = {
 | |
| 	kControlPushButtonDefaultTag : ("b", None, None),
 | |
| 	kControlEditTextTextTag: (None, None, None),
 | |
| 	kControlEditTextPasswordTag: (None, None, None),
 | |
| }
 | |
| 
 | |
| def SetControlData(control, part, selector, data):
 | |
| 	if not _codingdict.has_key(selector):
 | |
| 		raise KeyError, ('Unknown control selector', selector)
 | |
| 	structfmt, coder, decoder = _codingdict[selector]
 | |
| 	if coder:
 | |
| 		data = coder(data)
 | |
| 	if structfmt:
 | |
| 		data = struct.pack(structfmt, data)
 | |
| 	control.SetControlData(part, selector, data)
 | |
| 	
 | |
| def GetControlData(control, part, selector):
 | |
| 	if not _codingdict.has_key(selector):
 | |
| 		raise KeyError, ('Unknown control selector', selector)
 | |
| 	structfmt, coder, decoder = _codingdict[selector]
 | |
| 	data = control.GetControlData(part, selector)
 | |
| 	if structfmt:
 | |
| 		data = struct.unpack(structfmt, data)
 | |
| 	if decoder:
 | |
| 		data = decoder(data)
 | |
| 	return data
 | |
| 	
 |