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

G

GHUM

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
 
S

Simon Forman

GHUM said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,690
Members
48,796
Latest member
Greg L.

Latest Threads

Top