Mercurial > fife-parpg
comparison engine/extensions/pychan/properties.py @ 334:a9482d3d989e
PyChan fixes:
* DummyImage is gone for good.
* Renamed GuiImage.source annotation used in PyChan.
* Fixed a bug in an error path.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 24 Aug 2009 14:47:23 +0000 |
parents | fee958103d58 |
children | 162662bf5c8a |
comparison
equal
deleted
inserted
replaced
333:fee958103d58 | 334:a9482d3d989e |
---|---|
89 image_info["source"] = image | 89 image_info["source"] = image |
90 # to catch or not to catch ... | 90 # to catch or not to catch ... |
91 # we just let the NotFound exception trickle here. | 91 # we just let the NotFound exception trickle here. |
92 # depedning on complains we can catch and print a warning. | 92 # depedning on complains we can catch and print a warning. |
93 image_info["image"] = get_manager().loadImage(image) | 93 image_info["image"] = get_manager().loadImage(image) |
94 image_info["image"]._source = image | 94 image_info["image"].source = image |
95 self._getSetter(obj)(image_info["image"]) | 95 self._getSetter(obj)(image_info["image"]) |
96 | 96 |
97 elif isinstance(image,fife.GuiImage): | 97 elif isinstance(image,fife.GuiImage): |
98 # FIXME - this trickery with the hidden annotation | 98 # FIXME - this trickery with the hidden annotation |
99 # with an _source attribute isn't really clean. | 99 # with an _source attribute isn't really clean. |
100 # Is it even necessary | 100 # Is it even necessary |
101 image_info["source"] = getattr(image,"_source","") | 101 image_info["source"] = getattr(image,"source","") |
102 image_info["image"] = image | 102 image_info["image"] = image |
103 if image_info["source"]: | 103 if image_info["source"]: |
104 image_info["image"] = get_manager().loadImage(image) | 104 image_info["image"] = get_manager().loadImage(image) |
105 self._getSetter(obj)(image_info["image"]) | 105 self._getSetter(obj)(image_info["image"]) |
106 else: | 106 else: |
107 attribute_name = "%s.%s" % (obj.__class__.__name__,self.name) | 107 attribute_name = "%s.%s" % (obj.__class__.__name__,self.name) |
108 error_message = "%s only accepts GuiImage and python strings, not '%s'" | 108 error_message = "%s only accepts GuiImage and python strings, not '%s'" |
109 raise RuntimeError(error_message % (attribute_name, repr(source))) | 109 raise RuntimeError(error_message % (attribute_name, repr(image))) |
110 | 110 |
111 setattr(obj, self.prop_name, image_info) | 111 setattr(obj, self.prop_name, image_info) |
112 | 112 |
113 def __get__(self, obj, objtype = None): | 113 def __get__(self, obj, objtype = None): |
114 d = getattr(obj, self.prop_name, {}) | 114 d = getattr(obj, self.prop_name, {}) |
115 image = d.get("image",None) | 115 image = d.get("image",None) |
116 if not image: | 116 if not image: |
117 image = fife.GuiImage() | 117 image = fife.GuiImage() |
118 image.source = "" | |
118 return image | 119 return image |
119 | 120 |