Embedded Program Icon (wxPython)
Bart
bartweber at gmail.com
Sat Nov 29 15:30:27 EST 2008
Dear members,
It's not (yet) easy to find my way through the bunch of info scattered
over the internet to find out how to embed an icon. It could be that
I’m looking at the wrong places, I'm new to Python and wxPython.
Nevertheless, I would like to share this little script with the rest
of the world. Any suggestions are welcome!
Regards,
Bart
import wx
import cStringIO
import base64
def getImageStream():
img_b64 = \
"""iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAATlJREFUWIXNl2FyhCAMhV
+0B/NmCzfrHkxff+zSik0gCI77ZhwdCckHQoIi04w7Nd0a/
WMBuK0cHcjyKdYa4LZSplmanBXsrTYTQOvonZljHys4AHx5HWVgTBx5syjWpeBVgN+A75H/
BTbsmEBe9rXgQNcuqPp2qQqgj74cPJl61sxn5oGyxkx9B8BYZQDcVqbL7kLEGP691d55fGfb0LNtzsr0LdNcvQAQAPcKIZAESWTP5MsWAD2+b18DxVqwl5YPYowAgMcj7By
+787P2T0D+
+Bn5AZIIxKt4iSbxtE3AVylywFq9cBdjADf1B5tZJqlBFEEsE4zaR0sy4Ln8xsxBvUw4oEwAWpHqVZZEOap
+Iq0rPlUAa6sCS6AkrR8EELI2pr8nfk3bP0vGA5wBOn5ZF0AI3R7Kv4BLsO1PPzEcJMAAAAASUVORK5CYII="""
img = base64.b64decode(img_b64)
return img
class MyFrame(wx.Frame):
def __init__(self, parent, id, caption):
wx.Frame.__init__(self, parent, id, caption)
myStream = cStringIO.StringIO(getImageStream())
myImage = wx.ImageFromStream(myStream)
myBitmap = wx.BitmapFromImage(myImage)
myIcon = wx.EmptyIcon()
myIcon.CopyFromBitmap(myBitmap)
self.SetIcon(myIcon)
app = wx.PySimpleApp()
frame = MyFrame(None, -1, "Embedded Programm Icon Sample")
frame.Show(True)
app.MainLoop()
More information about the Python-list
mailing list