Miles Lee wrote:
> My goal is to draw shapes on the transparent background.
> 
> I did the research and found out two ways to get transparent
> background without floatcanvas.
> One way is to use wx.EVT_ERASE_BACKGROUND tricky,
> that is, leave the event handler empty.
> The other way is to take a screenshot to get a background
> image, then draw it on wx.Panel as background.
> 
> However,  the both do not work with floatcanvas.  For the former,
> I tried to bind the wx.EVT_ERASE_BACKGROUND to canvas.window

That's not going to work, as FloatCanvas is fully double buffered, so it 
fills the whole window every time.

Also, the code pre-dates any wx support for alpha channels in Bitmaps, 
the the buffer is opaque.

> and for the later, I tried to create dc like:
>              dc = wx.ClientDC(canvas.window)
>              dc.DrawBitmap(background_image, 0, 0, True)
> 
> So I tried this,
>       canvas = fc.NavCanvas(frame)
>     # take a screenshot to get backgound image
>       ...
>       canvas.create('Bitmap', background_image, pos = ......)
> 
> but the background_image is moveable, that is not I want.

right. With this construction, the background image is part of the main 
drawing, and it will move when you move around the canvas, as you have seen.

> How can I fix the background image in its position and the shapes drawn 
> on it can be moved, rotated and zoomed.

I can't think of a way to do that with the current structure, however:

> import wx.lib.floatcanvas.floatcanvas2 as fc

Ah, so this is FC2 -- same thinks apply, really. Except:

Matt, can the main buffer be a an alpha bitmap, and then you could set 
the background color to transparent, and do the wx.EVT_ERASE_BACKGROUND 
trick?


-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

[email protected]
_______________________________________________
FloatCanvas mailing list
[email protected]
http://paulmcnett.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to