Confused Newbie - wxImage vs WxImage pointer

K

Knoppix User

Hi there,

I am just starting up with Python, and loving it.

This snippet has me consomethingbobulated:


..................
jpgName = "/home/knoppix/Photos/Play/mvc00022.jpg"
img = wxImage(jpgName, wxBITMAP_TYPE_JPEG).ConvertToBitmap()
imgSmall = img.scale(100,100)
wxStaticBitmap(self, -1, imgSmall, pos = (120, 20), size= (100,100))
...................


I get this error:

Traceback (most recent call last):
File "GalleryTextProvider.py", line 152, in ?
app = MyApp(0)
File "/usr/lib/python2.3/site-packages/wxPython/wx.py", line 1951, in __init__
_wxStart(self.OnInit)
File "GalleryTextProvider.py", line 147, in OnInit
frame = MyFrame(NULL, -1, "GalleryTextProvider")
File "GalleryTextProvider.py", line 100, in __init__
imgSmall = img.scale(100,100)
AttributeError: wxBitmapPtr instance has no attribute 'scale'

If img is of type wxImage, how can it be pointer, and not a bitmap.

Any smacks to the head appreciated ( as long as they point me in the right
direction!

Steve
 
T

Tom

wxPython is a wrapper around wxWindows. The wxBitmapPtr is a handle to
the C++ object that is the actual object holding the bitmap.

Badly explained but that's basically it (For wxPython questions you
should try the wxPython mailing list).

Tom
 
K

Knoppix User

wxPython is a wrapper around wxWindows. The wxBitmapPtr is a handle to
the C++ object that is the actual object holding the bitmap.

Badly explained but that's basically it (For wxPython questions you
should try the wxPython mailing list).

Thanks, Tom. I'll take wxQuestions to the wxPython list - duh, sorry!

Steve
 
K

Knoppix User

It's a good place to go. In the meantime, the immediate
error is probably that you wanted to say `img.Scale`.

Yeah, but that's not the half of it :-( I received this very helpful reply
on the wxPython-users list. The main problem is that bitmaps don't have a
scale method. See below for more details.

Thanks for your input, Mel.

Steve


From: Markus Meyer

To: (e-mail address removed)
Subject: Re: [wxPython-users] Resizing wxImage
Date: Mon, 29 Dec 2003 16:39:13 +0100

Steve,

note that you're converting the image to a bitmap (via ConvertToBitmap).
Bitmaps don't have a scale method. wxImage has a scale method,
but it has an uppercase letter at the beginning.

You could use something like this:

img = wxImage(jpgName,wxBITMAP_TYPE_JPEG)
imgSmall = img.Scale(100, 100)
wxStaticBitmap(self, -1,wxBitmapFromImage(imgSmall))
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top