Windows Vista boxPython 2.7.2wxPython 2.8.12.0Looking at the wxPython demo for Alpha Drawing I thought I could adapt my code to include a to use the wx.GCDC so I could use the alpha channel for blending my drawing with the background and other elements.In the demo the wx.GCDC is built in the OnPaint method which is bound to the EVT_PAINT event. When I do this I get funky artifacts and the program breaks.If I just use the wx.ClientDC everything works great (except there is no alpha element which would be nice.)
When I do it, nothing "breaks" perse'... Just nothing draws on the client so I was under the impression GCDC only works with wx.PaintDC or I'm just not doing something right.Could someone show me a way (if possible) to use the wx.ClientDC and wx.GCDC together?
--
To unsubscribe, send email to wxPython-user...@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en
Did you remove the EVT_PAINT handler? If so then it is probably
repainting the default window content (the background) over whatever you
drew with the client DC.
Please make a small runnable sample that shows what you are trying to do
so we can see what is going wrong.
http://wiki.wxpython.org/MakingSampleApps
--
Robin Dunn
Software Craftsman
http://wxPython.org
Working on making the sample app now... should have it posted shortly. Trying to add worth while comments as well.
I Read Andrea's reply about using a thread for GUI manipulation. If I can do what I want to do in the main thread and not lock up the GUI in the mean time that would be great, but I'm shooting for some type of "animation" on a mouse over, and I'd like those animations to have an alpha channel.
For animation it is best to forget about using threads and simply use a
timer. Each iteration of the animation is performed in a single timer
event handler, and then you wait until the next timer event to do the
next iteration of the animation "loop". That keeps all UI interactions
in the main thread and still allows other events to be processed between
the animation iterations.
A basic flow could be something like this:
1. Something happens in the UI that you want to trigger some animation
2. Do any setup code needed, like getting/saving any parameters needed
for the animation.
3. Start() the timer
4. In the EVT_TIMER handler do one iteration of your animation loop
5. Setup for the next iteration of the animation loop if needed
6. If the animation is finished then Stop() the timer.
7. Return from the EVT_TIMER handler.
Depending on the platform and the nature of the animation it may be best
to not do any drawing at all in the timer handler, but rather just
change state as needed and then do a Refresh(rect=SomeRectangle) and
then do the drawing in the EVT_PAINT handler.
On Sun, Mar 11, 2012 at 10:36 PM, Steve Freedenburg
<stevefre...@gmail.com> wrote:
> In the demo the wx.GCDC is built in the OnPaint method which is bound to the
> EVT_PAINT event. When I do this I get funky artifacts and the program
> breaks.
> If I just use the wx.ClientDC everything works great (except there is no
> alpha element which would be nice.)
As Kevin mentioned, this isn't what wx.ClientDC is meant for. You may
find that it works well on Windows, but it could work really badly on
OS-X (and maybe GTK?) and perhaps even newer versions of Windows.
And I've been able to use wxGCDC just fine in Paint handlers, so there
is probably something else wrong.
> Please make a small runnable sample that shows what you are trying to do
> so we can see what is going wrong.
> http://wiki.wxpython.org/MakingSampleApps
you sent a sample, but;
- it wasn't nearly as small as it should be.
- it's better to enclose the code, rather than pasting into your email
-- email clinets can make a mess of Pyhton code.
the goal is to make it really, really easy for us to download, test
and debug your example -- in this case, I took one look, and decided
it was going to be too much effort to bother -- though I did notice
the use of threads, which as Robin pointed out is probably not worth
it (if it's even possible). But in any case, you seem to mixing issues
here:
- using GCDC to do your main drawing
- animation
I'd get the first one working first.
-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