Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
authorlbessard
Thu, 15 Jan 2009 10:05:07 +0100
changeset 294 39b3d4a2195b
parent 293 b9ec99fab9fc
child 295 bc6fc07c3153
Fix problem with embeddedimage module not present in wx versions older than 2.8.8.0
Beremiz_service.py
--- a/Beremiz_service.py	Wed Jan 14 19:50:09 2009 +0100
+++ b/Beremiz_service.py	Thu Jan 15 10:05:07 2009 +0100
@@ -85,7 +85,6 @@
 if enablewx:
     try:
         import wx, re
-        from wx.lib.embeddedimage import PyEmbeddedImage
         from threading import Thread
         from types import *
         havewx = True
@@ -93,6 +92,19 @@
         havewx = False
 
     if havewx:
+        try:
+            from wx.lib.embeddedimage import PyEmbeddedImage
+        except:
+            import cStringIO
+            import base64
+            
+            class PyEmbeddedImage:
+                def __init__(self, image_string):
+                    stream = cStringIO.StringIO(base64.b64decode(image_string))
+                    self.Image = wx.ImageFromStream(stream)
+                def GetImage(self):
+                    return self.Image
+        
         defaulticon = PyEmbeddedImage(
         "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAABc5J"
         "REFUSIl9lW1MW9cZx3/n2vf6BQO2MZiXGBISILCVUEUlitYpjaKpXZJ1XZZ2kzJVY9r6IeLD"