[wxPython] Images and DLLs/Python modules in wxPython

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Images and DLLs/Python modules in wxPython

Pieter Claerhout-3
Hello,

I was just wondering yesterday, if it's possible to embed
images in a DLL as a Python module? I would like to use
those images then in wxPython.

You may be wondering why I want to do that. I have several
reasons for that:

- You can always import a Python module and you don't have
  to worry about working directories.
- You can reduce the number of files of your final project
- Users can't access and use your images anymore
- You can compress a dll (using UPX or a similar utility)
  and so reduce the final size of your project.

Does anyone know if this is possible? If it is possible,
can anyone tell me how to accomplish that? Please keep in
mind that I'm not a C-programmer, and that I only have
basic knowledge on how to compile a program. I have a copy
of Microsoft Visual C++ 6.0.

Kind regards,


Pieter
PClaerhout@creo

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Images and DLLs/Python modules in wxPython

Robin Dunn
>
> I was just wondering yesterday, if it's possible to embed
> images in a DLL as a Python module? I would like to use
> those images then in wxPython.
>
> You may be wondering why I want to do that. I have several
> reasons for that:
>
> - You can always import a Python module and you don't have
>   to worry about working directories.
> - You can reduce the number of files of your final project
> - Users can't access and use your images anymore
> - You can compress a dll (using UPX or a similar utility)
>   and so reduce the final size of your project.
>
> Does anyone know if this is possible? If it is possible,
> can anyone tell me how to accomplish that? Please keep in
> mind that I'm not a C-programmer, and that I only have
> basic knowledge on how to compile a program. I have a copy
> of Microsoft Visual C++ 6.0.
>

wxImage can be constructed from a string of RGB values, so images could be
stored in any format you like (flat file, database, etc.) as long as you are
able to read it into a string to pass to wxImage.

The easiest way to do it in a DLL is to create an extension module, (see the
Extending/Embedding guide at python.org) and make functions that return the
image strings.

On the other hand, I have been thinking of ways to build an image archive
that could hold arbitrary image types and would make them accessible to
wxPython.  Stay tuned.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!




_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

RE: [wxPython] Images and DLLs/Python modules in wxPython

Pieter Claerhout-3
In reply to this post by Pieter Claerhout-3
Can you give an example on how to construct an image using a string
of RGB values?? Is there perhaps a utility that can do the conversion
for me??

Thankx,


Pieter

Pieter Claerhout - [hidden email]
Response Center - Applications Support

Creo Europe - Excelsiorlaan 21 - 1930 Zaventem - Belgium
Tel: +32 (2) 711 14 00 - Fax: +32 (2) 720 96 71


-----Original Message-----
From: Robin Dunn [mailto:[hidden email]]
Sent: Sunday, January 09, 2000 7:20 PM
To: wxPython-users
Subject: Re: [wxPython] Images and DLLs/Python modules in wxPython


>
> I was just wondering yesterday, if it's possible to embed
> images in a DLL as a Python module? I would like to use
> those images then in wxPython.
>
> You may be wondering why I want to do that. I have several
> reasons for that:
>
> - You can always import a Python module and you don't have
>   to worry about working directories.
> - You can reduce the number of files of your final project
> - Users can't access and use your images anymore
> - You can compress a dll (using UPX or a similar utility)
>   and so reduce the final size of your project.
>
> Does anyone know if this is possible? If it is possible,
> can anyone tell me how to accomplish that? Please keep in
> mind that I'm not a C-programmer, and that I only have
> basic knowledge on how to compile a program. I have a copy
> of Microsoft Visual C++ 6.0.
>

wxImage can be constructed from a string of RGB values, so images could be
stored in any format you like (flat file, database, etc.) as long as you are
able to read it into a string to pass to wxImage.

The easiest way to do it in a DLL is to create an extension module, (see the
Extending/Embedding guide at python.org) and make functions that return the
image strings.

On the other hand, I have been thinking of ways to build an image archive
that could hold arbitrary image types and would make them accessible to
wxPython.  Stay tuned.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!




_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Images and DLLs/Python modules in wxPython

Robin Dunn
> Can you give an example on how to construct an image using a string
> of RGB values?? Is there perhaps a utility that can do the conversion
> for me??
>

The mandelbrot program that was being passed around the list a few weeks ago
used wxImage that way.

--
Robin Dunn
Software Craftsman
[hidden email]
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!



_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

RE: [wxPython] Images and DLLs/Python modules in wxPython

Jeffrey Kunce
In reply to this post by Pieter Claerhout-3
>Can you give an example on how to construct an image using a string of RGB values??

Here's a code fragment that displays a PIL image (imgPil).
imgData is a RGB string as produced by PIL.

        if (imgPil.mode!='RGB'):
            imgPil = imgPil.convert('RGB')
        imgData = imgPil.tostring('raw','RGB')
        imgWx = wxEmptyImage(imgPil.size[0],imgPil.size[1])
        imgWx.SetData(imgData)
        dc.DrawBitmap(imgWx.ConvertToBitmap(), x1, y1)


  --Jeff


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users