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

Z

zxo102

Hi everyone,
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? 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
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top