Example #1
0
	def test_initWithParams(self):
		x = 42
		y = 67
		h = 600
		w = 800
		r = 12
		g = 34
		b = 89
		tag = 123
		viewTest = "test"
		
		view = WIView(WIBound(x,y,w,h), WIColor(r,g,b), tag)
		view.addSubview(viewTest)
		self.assertEqual(view.bounds.x, x)
		self.assertEqual(view.bounds.y, y)
		self.assertEqual(view.bounds.h, h)
		self.assertEqual(view.bounds.w, w)
		self.assertEqual(view.backgroundColor.red, r)
		self.assertEqual(view.backgroundColor.green, g)
		self.assertEqual(view.backgroundColor.blue, b)
		self.assertEqual(view.tag, tag)
		self.assertEqual(view.subviews, [viewTest])
Example #2
0
	def handleView(self, view):
		""" Get attributes """
		boundsAttr = view.getAttribute('bounds')
		tagAttr = view.getAttribute('tag')
		backgroundColorAttr = view.getAttribute('backgroundColor')
		userDefinedAttr = view.getAttribute('user-defined')
		""" Convert objects """
		bounds = self.getBounds(boundsAttr)
		tag = int(tagAttr)
		backgroundColor = self.getColor(backgroundColorAttr)
		userDefined = None
		if (userDefinedAttr == '0'):
			userDefined = False
		else:
			userDefined = True
		
		viewElement = None
		if (view.tagName == "WIView"):
			viewElement = WIView(bounds, backgroundColor, tag, userDefined)
		
		if (view.tagName == "WIImageView"):
			imageFilename = view.getAttribute('image')
			viewElement = WIImageView(bounds, backgroundColor, tag, imageFilename, userDefined)
		
		if (view.tagName == "WILabel"):
			text = view.getAttribute('text')
			textColorAttr = view.getAttribute('textColor')
			fontSizeAttr = view.getAttribute('fontSize')
			textColor = self.getColor(textColorAttr)
			fontSize = int(fontSizeAttr)
			viewElement = WILabel(bounds, backgroundColor, tag, text, textColor, fontSize, userDefined)
		
		subviews = self.handleSubviews(view)
		if (len(subviews) > 0):
			for subview in subviews:
				viewElement.addSubview(subview)
		return viewElement