win32 load icon not from file, but from <something>

Simon Forman rogue_pedro at yahoo.com
Thu Aug 10 16:02:47 EDT 2006


GHUM wrote:
> I have found a "make a icon in traybar" skript, and it loads its Icon
> from a file
>
> hinst =  win32gui.GetModuleHandle(None)
> iconPathName= "c:/myapp/myapp.ico"
> icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE
> hicon = win32gui.LoadImage(hinst, str(iconPathName),
> win32con.IMAGE_ICON, 0, 0, icon_flags)
>
> that works great.
>
> But now I have to distribute that icon together with the application -
> that is one file more to take track. I would like to load this image
> from <something>
> with something being a string / a cStringIO / something pickled
>
> The obvious
>
> cPickle.dumps(hicon) leads to nothing, cause it only gets the ID of the
> hicon :(
>
> Any ideas / recommendations / tipps?
>
> Harald

Write the data to a temporary file and load it from there.

(Also, iconPathName is already a string, you don't have to call
str(iconPathName).)

HTH,
~Simon




More information about the Python-list mailing list