I want to create a `wx.Image` from a file. Problem is, I have the
file, and not the file's name. (The reason for that is that I'm in
py2exe and all the files are in a big zipfile, so I `pkg_resources`
can't get their filename, but only as a stream.)
On Thu, Apr 29, 2010 at 12:53 PM, cool-RR <ram.rachum@gmail.com> wrote:
Hi,
I want to create a `wx.Image` from a file. Problem is, I have the
file, and not the file's name. (The reason for that is that I'm in
py2exe and all the files are in a big zipfile, so I `pkg_resources`
can't get their filename, but only as a stream.)
I went over it a few times and I don’t see an obvious answer. Is it LoadStream? I don’t understand how that works, given it takes a self. What self am I supposed to put into it.
I went over it a few times and I don’t see an obvious answer. Is it LoadStream? I don’t understand how that works, given it takes a self. What self am I supposed to put into it.
You were dismissive enough in your first message. But the things you’re saying are really not obvious, and one of them is wrong: There is such a thing as a staticmethod, that doesn’t take a self, which would actually have been a reasonable choice for LoadStream.
The fact that I’m supposed to create an empty image is not obvious; I did not
even know it was possible with the standard constructor.
Anyway, now I’m okay with wx.ImageFromStream, thanks.
FYI: there is a convinience function called wx.ImageFromStream that
you can use to.
Cody
Cody,
You were dismissive enough in your first message. But the things you’re saying are really not obvious, and one of them is wrong: There is such a thing as a staticmethod, that doesn’t take a self, which would actually have been a reasonable choice for LoadStream.
The fact that I’m supposed to create an empty image is not obvious; I did not
even know it was possible with the standard constructor.
Anyway, now I’m okay with wx.ImageFromStream, thanks.
1. Run the demo
2. Type "image" in the search control in the lower left corner
3. Click on the ImageFromStream sample revealed in the tree
4. Click on the Demo Code tab in the notebook
5. Read the source code
6. Be Happy
···
On 4/29/10 11:12 AM, cool-RR wrote:
On Thu, Apr 29, 2010 at 8:03 PM, Cody Precord <codyprecord@gmail.com > <mailto:codyprecord@gmail.com>> wrote:
Hi,
On Thu, Apr 29, 2010 at 12:53 PM, cool-RR <ram.rachum@gmail.com > <mailto:ram.rachum@gmail.com>> wrote:
> Hi,
>
> I want to create a `wx.Image` from a file. Problem is, I have the
> file, and not the file's name. (The reason for that is that I'm in
> py2exe and all the files are in a big zipfile, so I `pkg_resources`
> can't get their filename, but only as a stream.)
>
> Is this possible at all?
I went over it a few times and I don't see an obvious answer. Is it
`LoadStream`? I don't understand how that works, given it takes a
`self`. What `self` am I supposed to put into it.
Then what would be the best way to solve my problem? I have an ico file with plenty of differently-sized icons in it. I can’t load it as a filename, I can load it as a stream. I want that icon with all the different sizes to be used by my program. What do I do?
Ram
···
On Thu, Apr 29, 2010 at 9:00 PM, Robin Dunn robin@alldunn.com wrote:
On 4/29/10 11:46 AM, cool-RR wrote:
Now I have a question in a similar vein: How do I make an IconBundle
Either save the stream to a temporary file and load it from there, or split it into separate images that are loaded individually (you can then load them into an IconBundle at runtime if desired, or just use them individually as needed) or you can use img2py to put your images in Python code instead and just import them like any other Python module.
···
On 4/29/10 12:06 PM, cool-RR wrote:
On Thu, Apr 29, 2010 at 9:00 PM, Robin Dunn <robin@alldunn.com > <mailto:robin@alldunn.com>> wrote:
On 4/29/10 11:46 AM, cool-RR wrote:
Now I have a question in a similar vein: How do I make an
`IconBundle`
from a stream?
It is not supported.
--
Robin Dunn
Then what would be the best way to solve my problem? I have an `ico`
file with plenty of differently-sized icons in it. I can't load it as a
filename, I can load it as a stream. I want that icon with all the
different sizes to be used by my program. What do I do?
I think I will go with the solution of splitting them to different images. Just for the record, am I really supposed to be doing icon = IconFromBitmap(BitmapFromImage(ImageFromStream(stream)))?
Ram.
···
On Thu, Apr 29, 2010 at 10:04 PM, Robin Dunn robin@alldunn.com wrote:
On 4/29/10 11:46 AM, cool-RR wrote:
Now I have a question in a similar vein: How do I make an
`IconBundle`
from a stream?
It is not supported.
--
Robin Dunn
Then what would be the best way to solve my problem? I have an ico
file with plenty of differently-sized icons in it. I can’t load it as a
filename, I can load it as a stream. I want that icon with all the
different sizes to be used by my program. What do I do?
Either save the stream to a temporary file and load it from there, or split it into separate images that are loaded individually (you can then load them into an IconBundle at runtime if desired, or just use them individually as needed) or you can use img2py to put your images in Python code instead and just import them like any other Python module.