Steve wrote:
I was hoping to find an answer to a problem I have found in my code.
yup – don’t do that.
You can’t make GUI calls from another thread, and wx.Bitmap manipulation is a GUI call.
That clears that up.
Thanks.
I do a lot of manipulation on it to convert it to an RGB array and then call wx.BitmapFromBuffer and a few other wx.Bitmap calls before I send the data to be displayed via wx.CallAfter.
You’ll have to move your wx.Bitmap calls into the main thread. What else are you doing besides wx.BitmapFromBuffer maybe you can do that without wx calls (PIL or numpy or ?).
I am basically just reformatting my data so I can call wx.BitmapFromBuffer because I am sent a 1 dim array via the DB. Here is the section of my image processing:
data = numpy.fromstring (msg, dtype = numpy.uint16)
ndimg = data.reshape ((128, 128))
rgb = numpy.zeros ((128, 128, 3), dtype = numpy.uint16)
rgb[:,:,0] = rgb[:,:,1] = rgb[:,:,2] = ndimg
wfsImg = wx.BitmapFromBuffer (rgb.shape[0], rgb.shape[1], rgb)
tmpImg = wx.ImageFromBitmap (wfsImg)
if self.imgSize.GetValue() == 1:
do nothing
pass
if self.imgSize.GetValue() == 2:
tempImg.Rescale (256, 256)
if self.imgSize.GetValue() == 3:
tempImg.Rescale (384, 384)
if self.imgSize.GetValue() == 4:
tempImg.Rescale (512, 512)
self.image = wx.BitmapFromImage (tmpImg)
wx.CallAfter (self.window.UpdateDisplay, self.image)
There doesn’t seem to be any issue when doing it in my main thread, with regard to speed, but I figured I would have the thread do it since it was the one getting the data.
Kind Regards,
Steve
···
On Wed, May 26, 2010 at 1:04 AM, Christopher Barker Chris.Barker@noaa.gov wrote:
-Chris
–
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (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, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en