changeset 188:06dddc96ce54

* Fixed some space and tab mixing * Fixed a small bug in manager.py, thanks to phoku for the pointer.
author nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
date Thu, 26 Feb 2009 11:26:01 +0000
parents 644bf7ca1e0a
children 3d0cc4545938
files build/freebsd6-config-dist.py engine/extensions/pychan/__init__.py engine/extensions/pychan/attrs.py engine/extensions/pychan/events.py engine/extensions/pychan/manager.py engine/extensions/pychan/widgets.py
diffstat 6 files changed, 62 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/build/freebsd6-config-dist.py	Wed Feb 25 20:58:09 2009 +0000
+++ b/build/freebsd6-config-dist.py	Thu Feb 26 11:26:01 2009 +0000
@@ -27,5 +27,5 @@
 		context.env.Append(CPPPATH = ['/usr/local/include'])
 		context.env.Append(LIBPATH = ['/usr/local/lib'])
 		context.checkSimpleLib(['guichan_opengl'])
-        # For swig/python:
-        context.env.Append(CPPPATH = ['/usr/local/include/python%s'%sys.version[:3]])
+	# For swig/python:
+	context.env.Append(CPPPATH = ['/usr/local/include/python%s'%sys.version[:3]])
--- a/engine/extensions/pychan/__init__.py	Wed Feb 25 20:58:09 2009 +0000
+++ b/engine/extensions/pychan/__init__.py	Thu Feb 26 11:26:01 2009 +0000
@@ -163,18 +163,18 @@
 
 The font definition files are in the following format::
 	[Font/FIRST_FONT_NAME]
-	
+
 	type: truetype
 	source: path/to/font.ttf
 	# The font size in point
 	size: 30
-	
+
 	[Font/SECOND_FONT_NAME]
-	
+
 	type: truetype
 	source: content/fonts/samanata.ttf
 	size: 8
-	
+
 	# And so on.
 
 I hope the example is clear enough ... Other options you can set:
@@ -241,7 +241,7 @@
 	"""
 	This has to be called before any other pychan methods can be used.
 	It sets up a manager object which is available under pychan.manager.
-	
+
 	@param engine: The FIFE engine object.
 	"""
 	from manager import Manager
@@ -292,7 +292,7 @@
 	def _setAttr(self,obj,name,value):
 		if not hasattr(obj.__class__,'ATTRIBUTES'):
 			raise PyChanException("The registered widget/spacer class %s does not supply an 'ATTRIBUTES'."
-				% repr(obj))
+								  % repr(obj))
 		try:
 			for attr in obj.ATTRIBUTES:
 				if attr.name == name:
--- a/engine/extensions/pychan/attrs.py	Wed Feb 25 20:58:09 2009 +0000
+++ b/engine/extensions/pychan/attrs.py	Thu Feb 26 11:26:01 2009 +0000
@@ -10,7 +10,7 @@
 Usage::
   class SomeObject:
       nameAttr, posAttr = [ Attr("name"), PointAttr("pos") ]
-  
+
   obj =  SomeObject()
   obj.nameAttr.set(obj,"newName")
   obj.posAttr.set(obj,"89,89")
@@ -85,7 +85,7 @@
 			return value
 		except:
 			raise ParserError("Expected a 0 or 1.")
-			
+
 class FloatAttr(Attr):
 	def parse(self, value):
 		try:
--- a/engine/extensions/pychan/events.py	Wed Feb 25 20:58:09 2009 +0000
+++ b/engine/extensions/pychan/events.py	Thu Feb 26 11:26:01 2009 +0000
@@ -175,7 +175,7 @@
 				if not self.listener.events:
 					self.detach()
 			elif self.debug:
-					print CALLBACK_NONE_MESSAGE % str(self.widget)
+				print CALLBACK_NONE_MESSAGE % str(self.widget)
 			return
 
 		if not callable(callback):
--- a/engine/extensions/pychan/manager.py	Wed Feb 25 20:58:09 2009 +0000
+++ b/engine/extensions/pychan/manager.py	Thu Feb 26 11:26:01 2009 +0000
@@ -27,7 +27,7 @@
 		self.styles = {}
 		self.addStyle('default',DEFAULT_STYLE)
 
-                Manager.manager = self
+		Manager.manager = self
 
 		# Setup synchronous dialogs
 		self.mainLoop = None
@@ -125,8 +125,8 @@
 		return style_copy
 
 	def loadImage(self,filename):
-		index = self.engine.imagePool.addResourceFromFile(filename)
-		return fife.GuiImage(index,self.engine.imagePool)
+		index = self.engine.getImagePool().addResourceFromFile(filename)
+		return fife.GuiImage(index,self.engine.getImagePool())
 
 # Default Widget style.
 
@@ -137,34 +137,34 @@
 		'base_color' : fife.Color(0,0,100),
 		'foreground_color' : fife.Color(255,255,255),
 		'background_color' : fife.Color(0,0,0),
-	},
+		},
 	'Button' : {
 		'border_size': 0,
 		'margins' : (10,5),
-	},
+		},
 	('CheckBox','RadioButton') : {
 		'border_size': 0,
-	},
+		},
 	'TextBox' : {
 		'border_size' : 0,
-	},
+		},
 	'Label' : {
 		'border_size': 0,
-	},
+		},
 	'ListBox' : {
 		'border_size': 0,
-	},
+		},
 	'Window' : {
 		'border_size': 1,
 		'margins': (5,5),
-	},
+		},
 	('Container','HBox','VBox') : {
 		'border_size': 0,
 		'opaque' : False
-	},
+		},
 	'Icon' : {
 		'border_size' : 0
-	},
+		},
 	'Slider' : {
 		'border_size' : 0
 	}
--- a/engine/extensions/pychan/widgets.py	Wed Feb 25 20:58:09 2009 +0000
+++ b/engine/extensions/pychan/widgets.py	Thu Feb 26 11:26:01 2009 +0000
@@ -14,8 +14,8 @@
 from attrs import Attr,PointAttr,ColorAttr,BoolAttr,IntAttr,FloatAttr
 
 def get_manager():
-    import pychan
-    return pychan.manager
+	import pychan
+	return pychan.manager
 
 def _mungeText(text):
 	"""
@@ -90,14 +90,14 @@
 	DEFAULT_NAME = '__unnamed__'
 
 	HIDE_SHOW_ERROR = """\
-	You can only show/hide the top widget of a hierachy.
-	Use 'addChild' or 'removeChild' to add/remove labels for example.
-	"""
+		You can only show/hide the top widget of a hierachy.
+		Use 'addChild' or 'removeChild' to add/remove labels for example.
+		"""
 
 	def __init__(self,parent = None, name = DEFAULT_NAME,
-			size = (-1,-1), min_size=(0,0), max_size=(5000,5000),
-			style = None, **kwargs):
-		
+				 size = (-1,-1), min_size=(0,0), max_size=(5000,5000),
+				 style = None, **kwargs):
+
 		assert( hasattr(self,'real_widget') )
 		self.event_mapper = events.EventMapper(self)
 		self._visible = False
@@ -169,7 +169,7 @@
 	def capture(self, callback, event_name="action", group_name="default"):
 		"""
 		Add a callback to be executed when the widget event occurs on this widget.
-		
+
 		The callback must be either a callable or None.
 		The old event handler (if any) will be overridden by the callback.
 		If None is given, the event will be disabled. You can query L{isCaptured}
@@ -235,9 +235,9 @@
 		      VBox 1
 		      - Container
 			- VBox 2
-			  - HBox 
+			  - HBox
 			    - Label
-		
+
 		If you call adaptLayout on the Label the layout from the VBox 2
 		will get recalculated, while the VBox 1 stays untouched.
 
@@ -323,7 +323,7 @@
 		widget names and override the previously set callback.
 		You can also pass C{None} instead of a callback, which will
 		disable the event completely.
-		
+
 		@param eventMap: A dictionary with widget/event names as keys and callbacks as values.
 		@param ignoreMissing: Normally this method raises an RuntimeError, when a widget
 		can not be found - this behaviour can be overriden by passing True here.
@@ -401,13 +401,13 @@
 		Distribute data from a dictionary over the widgets in the hierachy
 		using the keys as names and the values as the data (which is set via L{setData}).
 		This will only accept unique matches.
-		
+
 		Use it like this::
 		  guiElement.distributeData({
 		       'myTextField' : 'Hello World!',
 		       'myListBox' : ["1","2","3"]
 		  })
-		
+
 		"""
 		for name,data in dataMap.items():
 			widgetList = self.findChildren(name = name)
@@ -965,7 +965,7 @@
 	A horizontally aligned box - for containement of child widgets.
 
 	Please see L{VBox} for details - just change the directions :-).
-	"""	
+	"""
 	def __init__(self,padding=5,**kwargs):
 		super(HBox,self).__init__(**kwargs)
 		self.padding = padding
@@ -1100,7 +1100,7 @@
 	 Currently to actually see text wrapping you have to explicitly set a max_size with
 	 the desired width of the text, as the layout engine is not capable of deriving
 	 the maximum width from a parent container.
-	 
+
 	"""
 
 	ATTRIBUTES = BasicTextWidget.ATTRIBUTES + [BoolAttr('wrap_text')]
@@ -1109,14 +1109,14 @@
 		self.real_widget = fife.Label("")
 		self.wrap_text = wrap_text
 		super(Label,self).__init__(**kwargs)
-		
+
 	def resizeToContent(self):
 		self.real_widget.setWidth( self.max_size[0] )
 		self.real_widget.adjustSize()
 		self.height = self.real_widget.getHeight() + self.margins[1]*2
 		self.width  = self.real_widget.getWidth()  + self.margins[0]*2
 		#print self.width,self.max_size[0]
-	
+
 	def _setTextWrapping(self,wrapping): self.real_widget.setTextWrapping(wrapping)
 	def _getTextWrapping(self): self.real_widget.isTextWrapping()
 	wrap_text = property(_getTextWrapping,_setTextWrapping)
@@ -1189,7 +1189,7 @@
 		except:
 			self._hoverimage = _DummyImage()
 	def _getHoverImage(self): return self._hoverimage_source
-	hover_image = property(_getHoverImage,_setHoverImage)	
+	hover_image = property(_getHoverImage,_setHoverImage)
 
 	def _setOffset(self, offset):
 		self.real_widget.setDownOffset(offset[0], offset[1])
@@ -1211,7 +1211,7 @@
 	"""
 	A basic push button that can be toggled.
 
-	Unfortunately a bit of code duplication from ImageButton.	
+	Unfortunately a bit of code duplication from ImageButton.
 
 	New Attributes
 	==============
@@ -1223,7 +1223,7 @@
 	ATTRIBUTES = BasicTextWidget.ATTRIBUTES + [Attr('up_image'),Attr('down_image'),PointAttr('offset'),Attr('helptext'),Attr('hover_image'),Attr('group')]
 
 	def __init__(self,up_image="",down_image="",hover_image="",offset=(0,0),group="",**kwargs):
-		
+
 		self.real_widget = fife.ToggleButton()
 		super(ToggleButton,self).__init__(**kwargs)
 		self.group = group
@@ -1231,17 +1231,17 @@
 		self.down_image = down_image
 		self.hover_image = hover_image
 		self.offset = offset
-		
+
 	def _setGroup(self,group):
 		self.real_widget.setGroup( group )
-		
+
 	def _getGroup(self):
 		return self.real_widget.getGroup()
 	group = property(_getGroup,_setGroup)
-	
+
 	def _setToggled(self, toggled):
 		self.real_widget.setToggled( toggled )
-		
+
 	def _isToggled(self):
 		return self.real_widget.isToggled()
 	toggled = property(_isToggled, _setToggled)
@@ -1278,7 +1278,7 @@
 		except:
 			self._hoverimage = _DummyImage()
 	def _getHoverImage(self): return self._hoverimage_source
-	hover_image = property(_getHoverImage,_setHoverImage)	
+	hover_image = property(_getHoverImage,_setHoverImage)
 
 	def _setOffset(self, offset):
 		self.real_widget.setDownOffset(offset[0], offset[1])
@@ -1653,7 +1653,7 @@
 		self.content.height = max(self.content.height,self.height-5)
 
 	def _visibilityToScrollPolicy(self,visibility):
-		if visibility: 
+		if visibility:
 			return fife.ScrollArea.SHOW_AUTO
 		return fife.ScrollArea.SHOW_NEVER
 
@@ -1701,7 +1701,7 @@
 
 class Slider(Widget):
 	""" A slider widget
-	
+
 	Use a callback to read out the slider value every time the marker
 	is moved.
 
@@ -1711,40 +1711,40 @@
 	  - orientation: 1 = horizontal, 0=vertical
 	  - scale_start: float: default 0.0
 	  - scale_end: float: default 1.0
-	
+
 	FIXME:
 		- set new attributes for marker & step length, value
-		- update docstrings		
+		- update docstrings
 	"""
-	
+
 	HORIZONTAL = fife.Slider.HORIZONTAL
 	VERTICAL = fife.Slider.VERTICAL
-	
+
 	ATTRIBUTES = Widget.ATTRIBUTES + [IntAttr('orientation'), FloatAttr('scale_start'), FloatAttr('scale_end')]
-	
+
 	def __init__(self, scaleStart=0.0, scaleEnd=1.0, orientation=HORIZONTAL, **kwargs):
 		self.real_widget = fife.Slider(scaleStart, scaleEnd)
 		self.orientation = orientation
 		self.setOrientation(self.orientation)
 		super(Slider, self).__init__(**kwargs)
-	
+
 	def _setScale(self, start, end):
 		"""setScale(self, double scaleStart, double scaleEnd)"""
 		if type(start) != float:
 			raise RuntimeError("Slider expects float for start scale")
 		if type(end) != float:
-			raise RuntimeError("Slider expects float for end scale")		
+			raise RuntimeError("Slider expects float for end scale")
 		self.real_widget.setScale(start, end)
-	
+
 	def getScaleStart(self):
 		"""getScaleStart(self) -> double"""
 		return self.real_widget.getScaleStart()
-		
+
 	def setScaleStart(self, start):
 		"""setScaleStart(self, double scaleStart)"""
 		if type(start) != float:
 			raise RuntimeError("Slider expects float for start scale")
-		self.real_widget.setScaleStart(start)		
+		self.real_widget.setScaleStart(start)
 	scale_start = property(getScaleStart, setScaleStart)
 
 	def getScaleEnd(self):
@@ -1781,7 +1781,7 @@
 	def setOrientation(self, orientation):
 		"""setOrientation(self, Orientation orientation)"""
 		self.real_widget.setOrientation(orientation)
-		
+
 	def getOrientation(self):
 		"""getOrientation(self) -> int"""
 		return self.real_widget.getOrientation()