| 87 | return self.search_app_instance(node.get_parent()) |
| 88 | |
| 89 | def update(self, *args): |
| 90 | if self.app_instance==None: |
| 91 | self.app_instance = self.search_app_instance(self) |
| 92 | if self.app_instance==None: |
| 93 | self.attributes['src'] = "/%s/get_image_data?index=00"%self.identifier #gui.load_resource(self.filename) |
| 94 | return |
| 95 | self.app_instance.execute_javascript(""" |
| 96 | url = '/%(id)s/get_image_data?index=%(frame_index)s'; |
| 97 | |
| 98 | xhr = null; |
| 99 | xhr = new XMLHttpRequest(); |
| 100 | xhr.open('GET', url, true); |
| 101 | xhr.responseType = 'blob' |
| 102 | xhr.onload = function(e){ |
| 103 | urlCreator = window.URL || window.webkitURL; |
| 104 | urlCreator.revokeObjectURL(document.getElementById('%(id)s').src); |
| 105 | imageUrl = urlCreator.createObjectURL(this.response); |
| 106 | document.getElementById('%(id)s').src = imageUrl; |
| 107 | } |
| 108 | xhr.send(); |
| 109 | """ % {'id': self.identifier, 'frame_index':str(time.time())}) |
| 110 | |
| 111 | def get_image_data(self, index=0): |
| 112 | gui.Image.set_image(self, '/%(id)s/get_image_data?index=%(frame_index)s'% {'id': self.identifier, 'frame_index':str(time.time())}) |