after an image is moved to a new location, how to delete the image at the old location?

Hi everyone,

 I need your help. What I want to do is to move an image around based on location data in wxpython.
 As shown in the code below (modified based on the Image.py in

wxpython demo), an image is created at location 1: (50,10) with
rotated angle 1.12. Now, suppose I got another set of new data, I want
to move the image to location 2: (166,400) with rotated angle 1.5.
case 1:
if I use
“wx.StaticBitmap(panel, -1, bmp2, (166, 400), (bmp2.GetWidth(),
bmp2.GetHeight()))”,
everything is fine but I don’t know how to delete the image at
location 1.
case 2:
If I use
“kk.SetBitmap(bmp2)” (see the code below),
the rotated image (angle
1.5) is put to location 1: (50,10)
instead of location 2: (166,400). Or I don’t know how to move the image
to the new location (166,400).

Anybody knows how to solve the above problem? or is there other way to implement it?

Thanks a lot.

Ouyang

···

#############################################
def runTest(frame, nb, log):
bmp = wx.Image(opj(‘bitmaps/image.bmp’), wx.BITMAP_TYPE_BMP)
bmp.SetMask(True)

image.bmp is originally located in (50,10) with rotated angle

1.12
x = 50
y = 10
angle = 1.12
bmp1 = bmp.Rotate(angle, (x,y), True,None)
bmp1 = bmp1.ConvertToBitmap()
panel = wx.Panel(nb,
-1)
kk = wx.StaticBitmap(panel, -1, bmp1, (x, y), (bmp1.GetWidth(),
bmp1.GetHeight()))

Now image.bmp is relocated at (166,400) with rotated angle 1.5

x= 166
y = 400
angle = 1.5
bmp2 = bmp.Rotate(angle, (x,y), True,None)
bmp2 = bmp2.ConvertToBitmap()
wx.StaticBitmap(panel, -1, bmp2, (x,y), (bmp2.GetWidth(),
bmp2.GetHeight()))
#kk.SetBitmap(bmp2)
return panel
###########################################################3


How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.

zxo102 wrote:

     As shown in the code below (modified based on the Image.py in
wxpython demo), an image is created at location 1: (50,10) with
rotated angle 1.12. Now, suppose I got another set of new data, I want
to move the image to location 2: (166,400) with rotated angle 1.5.
case 1:
     if I use
     "wx.StaticBitmap(panel, -1, bmp2, (166, 400), (bmp2.GetWidth(),
bmp2.GetHeight()))",
     everything is fine but I don't know how to delete the image at
location 1.

you can delete with kk.Destroy()

case 2:
     If I use
     "kk.SetBitmap(bmp2)" (see the code below),
     the rotated image (angle 1.5) is put to location 1: (50,10)
instead of location 2: (166,400). Or I don't know how to move the image
to the new location (166,400).

kk.Move((166,400))

I'd do that, no reason to destroy one and make another.

You might also want to consider just drawing the Bitmap to Window with a wx.DC -- see the Wiki and/or the demo for examples.

Also, depending on what else you want wx.lib.floatcanvas may will give you a lot more features.

-Chris

···

--
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