img2py

im not sure if this is a wxpython question or just a python question but i need help. im using img2py to embed pictures into a .py script. my question is how do i get them out? i tried to call the image with this:

dwpic = wx.Image(macroicons.getdwiconBitmap())

and this is the error i get:

TypeError: String or Unicode type required

could anybody help.

Hi Justin,

justin mcguire wrote:

im not sure if this is a wxpython question or just a python question but i need help. im using img2py to embed pictures into a .py script. my question is how do i get them out? i tried to call the image with this:

dwpic = wx.Image(macroicons.getdwiconBitmap())

and this is the error i get:

TypeError: String or Unicode type required

If you look at your macroicons.py file you will see that there three functions defined for each image:

E.g. in my file have an image called "bottle".

def getbottleBitmap():
    return BitmapFromImage(getbottleImage())

def getbottleImage():
    stream = cStringIO.StringIO(getbottleData())
    return ImageFromStream(stream)

def getbottleIcon():
    icon = EmptyIcon()
    icon.CopyFromBitmap(getbottleBitmap())
    return icon

So, if you want an image just do:

dwpic = macroicons.getdwiconImage()

Werner

···

could anybody help.

ok i changed the line from:

dwpic = wx.Image(macroicons.getdwiconBitmap())

to:

dwpic = macroicons.getdwiconImage()

im trying to put it in a sizer and i get this error:

TypeError: wx.Window, wx.Sizer, wx.Size, or (w,h) expected for item

···

On 10/10/06, Werner F. Bruhin < werner.bruhin@free.fr> wrote:

Hi Justin,

justin mcguire wrote:

im not sure if this is a wxpython question or just a python question

but i need help. im using img2py to embed pictures into a .py script.
my question is how do i get them out? i tried to call the image with
this:

dwpic = wx.Image(macroicons.getdwiconBitmap
())

and this is the error i get:

TypeError: String or Unicode type required

If you look at your macroicons.py file you will see that there three
functions defined for each image:

E.g. in my file have an image called “bottle”.

def getbottleBitmap():
return BitmapFromImage(getbottleImage())

def getbottleImage():
stream = cStringIO.StringIO(getbottleData())

return ImageFromStream(stream)

def getbottleIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getbottleBitmap())
return icon

So, if you want an image just do:

dwpic = macroicons.getdwiconImage
()

Werner

could anybody help.


To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Hi Justin,

justin mcguire wrote:

ok i changed the line from:

dwpic = wx.Image(macroicons.getdwiconBitmap())

to:

dwpic = macroicons.getdwiconImage()

im trying to put it in a sizer and i get this error:

TypeError: wx.Window, wx.Sizer, wx.Size, or (w,h) expected for item

A wx.Image instance is NOT a wx.Window. You need a control to show this image, e.g. a wx.StaticBitmap or a wx.BitmapButton etc.

What do you want to do with this image, what is it?

Werner

···

On 10/10/06, *Werner F. Bruhin* < werner.bruhin@free.fr > <mailto:werner.bruhin@free.fr>> wrote:

    Hi Justin,

    justin mcguire wrote:

    > im not sure if this is a wxpython question or just a python
    question
    > but i need help. im using img2py to embed pictures into a .py
    script.
    > my question is how do i get them out? i tried to call the image
    with
    > this:
    >
    > dwpic = wx.Image(macroicons.getdwiconBitmap ())
    >
    > and this is the error i get:
    >
    > TypeError: String or Unicode type required

    If you look at your macroicons.py file you will see that there three
    functions defined for each image:

    E.g. in my file have an image called "bottle".

    def getbottleBitmap():
        return BitmapFromImage(getbottleImage())

    def getbottleImage():
        stream = cStringIO.StringIO(getbottleData())
        return ImageFromStream(stream)

    def getbottleIcon():
        icon = EmptyIcon()
        icon.CopyFromBitmap(getbottleBitmap())
        return icon

    So, if you want an image just do:

    dwpic = macroicons.getdwiconImage ()

    Werner

    >
    > could anybody help.

    ---------------------------------------------------------------------
    To unsubscribe, e-mail:
    wxPython-users-unsubscribe@lists.wxwidgets.org
    <mailto:wxPython-users-unsubscribe@lists.wxwidgets.org>
    For additional commands, e-mail:
    wxPython-users-help@lists.wxwidgets.org
    <mailto:wxPython-users-help@lists.wxwidgets.org>

ya know your right i dont know what i was thinking, its a picture that i want to place on a panel that has a sizer, normally i would use a wx.Image() object and put where i want it in the ()
dwpic = wx.Image(basepanel))

but i cannot add the location into the () for this, is there a different way to add something to a panel?

···

On 10/10/06, Werner F. Bruhin < werner.bruhin@free.fr> wrote:

Hi Justin,

justin mcguire wrote:

ok i changed the line from:

dwpic = wx.Image(macroicons.getdwiconBitmap())

to:

dwpic = macroicons.getdwiconImage()

im trying to put it in a sizer and i get this error:

TypeError: wx.Window, wx.Sizer, wx.Size, or (w,h) expected for item

A wx.Image instance is NOT a wx.Window. You need a control to show this
image, e.g. a wx.StaticBitmap or a wx.BitmapButton etc.

What do you want to do with this image, what is it?

Werner

On 10/10/06, Werner F. Bruhin < werner.bruhin@free.fr > > <mailto:werner.bruhin@free.fr > >> wrote:

Hi Justin,

justin mcguire wrote:

> im not sure if this is a wxpython question or just a python
question
> but i need help.  im using img2py to embed pictures into a .py
script.
> my question is how do i get them out?  i tried to call the image
with
> this:
>
> dwpic = wx.Image(macroicons.getdwiconBitmap ())
>
> and this is the error i get:
>
> TypeError: String or Unicode type required

If you look at your macroicons.py file you will see that there three
functions defined for each image:

E.g. in my file have an image called "bottle".

def getbottleBitmap():
    return BitmapFromImage(getbottleImage())
def getbottleImage():
    stream = cStringIO.StringIO(getbottleData())
    return ImageFromStream(stream)

def getbottleIcon():
    icon = EmptyIcon()
    icon.CopyFromBitmap(getbottleBitmap())
    return icon

So, if you want an image just do:

dwpic = macroicons.getdwiconImage ()

Werner
>
>
> could anybody help.



---------------------------------------------------------------------
To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org
<mailto:wxPython-users-unsubscribe@lists.wxwidgets.org

For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org
<mailto:

wxPython-users-help@lists.wxwidgets.org>


To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

justin mcguire wrote:

ya know your right i dont know what i was thinking, its a picture that i want to place on a panel that has a sizer, normally i would use a wx.Image() object and put where i want it in the ()
dwpic = wx.Image(basepanel))

huh? I don't think you can do that at all.

but i cannot add the location into the () for this, is there a different way to add something to a panel?

If you just want the image, use:

dwpic = macroicons.getdwiconBitmap()

Sizer.Add(wx.StaticBitmap(dwpic)

A wx.Bitmap is a platform native version of a bitmap.

A wx.Image is a platform neutral 24bit RGB ini-memory version of an image.

Neither can be displayed directly, you need to put a Bitmap in a control of some sort:

wx.StaticBitmap
wx.BitmapButtton

or a custom class of some sort, derived from wx.,Window or wx,panel, in which you draw the Bitmap yourself with DCs.

see:

http://wiki.wxpython.org/index.cgi/RecipesImagesAndGraphics

For lots more info.

-CHB

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

if i do it as you say then i get this error:

TypeError: argument number 1: a ‘wxWindow *’ is expected, ‘PySwigObject(_p_wxImage)’ is received

···

On 10/10/06, Christopher Barker Chris.Barker@noaa.gov wrote:

justin mcguire wrote:

ya know your right i dont know what i was thinking, its a picture that i
want to place on a panel that has a sizer, normally i would use a
wx.Image() object and put where i want it in the ()

dwpic = wx.Image(basepanel))

huh? I don’t think you can do that at all.

but i cannot add the location into the () for this, is there a different
way to add something to a panel?

If you just want the image, use:

dwpic = macroicons.getdwiconBitmap()

Sizer.Add(wx.StaticBitmap(dwpic)

A wx.Bitmap is a platform native version of a bitmap.

A wx.Image is a platform neutral 24bit RGB ini-memory version of an image.

Neither can be displayed directly, you need to put a Bitmap in a control
of some sort:

wx.StaticBitmap
wx.BitmapButtton

or a custom class of some sort, derived from wx.,Window or wx,panel, in

which you draw the Bitmap yourself with DCs.

see:

http://wiki.wxpython.org/index.cgi/RecipesImagesAndGraphics

For lots more info.

-CHB


Christopher Barker, Ph.D.
Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov


To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

justin mcguire wrote:

if i do it as you say then i get this error:

TypeError: argument number 1: a 'wxWindow *' is expected, 'PySwigObject(_p_wxImage)' is received

Looks like Chris left out a couple parameters. Try something like wx.StaticBitmap(panel, -1, dwpic)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

thanks that worked perfectly

···

On 10/10/06, Robin Dunn robin@alldunn.com wrote:

justin mcguire wrote:

if i do it as you say then i get this error:

TypeError: argument number 1: a ‘wxWindow *’ is expected,
‘PySwigObject(_p_wxImage)’ is received

Looks like Chris left out a couple parameters. Try something like

wx.StaticBitmap(panel, -1, dwpic)


Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org

justin mcguire wrote:

if i do it as you say then i get this error:

That's what I get for posting untested code. Try this (still untested!):

Sizer.Add(wx.StaticBitmap(parent, bitmap=dwpic)

Where parent is the wx.Widow that you want the Bitmap draw on. Every wx.Window constructor takes the parent as the first argument.

I've enclosed a little sample I put together that shows some of what you can do with a wx.StaticBitmap

-Chris

StaticBitmap.py (2.59 KB)

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov