gradient flicker revisited-now only with bitmaps

C M wrote:

Awhile ago Robin helped me as to how I could get a gradient
panel background without the drawn DC objects flickering during
resizes and such. That worked great, but I realize now that the
way I have it set up, I am getting flickering of bitmapbuttons but
not other widgets.

Attached is a runnable sample that reproduces the problem and
a bitmap to test it with. You will have to change the path to the
bitmap accordingly if you don't mind (I didn't know how to embed
an image right in the code).

The bitmap button flickers badly when resizing, but nothing
else does. Could someone explain what I am doing wrong?

Nothing. If you put a wx.BitmapButton on a panel with wx.FULL_REPAINT_ON_RESIZE style it is going to flicker on Windows. Apparently it is not being clipped in that case and the parent is drawing over it.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

So does that mean that that the following are mutually exclusive?:

1. Running on Windows
2. Gradient background
3. Able to resize the frame
4. Using wx.BitmapButtons (or, as I saw later, the generic bitmap buttons too)
5. No flickering on resizing
6. Proper redrawing of gradient on resizing

Or could there be a way to do this? I have found a way to have all but 6,
or all but 5, but not all of them together. If there is no other way
I will either
drop the idea of having a gradient (though it looks nice), or go with all but 6
since the error in not redrawing the gradient right only creates a light line
that is not nearly as unpleasant as the flickering.

Thanks,
Che

···

On Thu, May 29, 2008 at 2:25 AM, Robin Dunn <robin@alldunn.com> wrote:

C M wrote:

Awhile ago Robin helped me as to how I could get a gradient
panel background without the drawn DC objects flickering during
resizes and such. That worked great, but I realize now that the
way I have it set up, I am getting flickering of bitmapbuttons but
not other widgets.

Attached is a runnable sample that reproduces the problem and
a bitmap to test it with. You will have to change the path to the
bitmap accordingly if you don't mind (I didn't know how to embed
an image right in the code).

The bitmap button flickers badly when resizing, but nothing
else does. Could someone explain what I am doing wrong?

Nothing. If you put a wx.BitmapButton on a panel with
wx.FULL_REPAINT_ON_RESIZE style it is going to flicker on Windows.
Apparently it is not being clipped in that case and the parent is drawing
over it.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

It seems to work--great! I certainly would not have figured that out
on my own. Thank you.

I took it from your previous statement regarding Windows, if I ever
port what I'm doing to Mac and Linux it shouldn't have this type of
flicker issue in the first place--is that right?

Che

···

On Mon, Jun 2, 2008 at 1:21 AM, Robin Dunn <robin@alldunn.com> wrote:

C M wrote:

On Thu, May 29, 2008 at 2:25 AM, Robin Dunn <robin@alldunn.com> wrote:

C M wrote:

Awhile ago Robin helped me as to how I could get a gradient
panel background without the drawn DC objects flickering during
resizes and such. That worked great, but I realize now that the
way I have it set up, I am getting flickering of bitmapbuttons but
not other widgets.

Attached is a runnable sample that reproduces the problem and
a bitmap to test it with. You will have to change the path to the
bitmap accordingly if you don't mind (I didn't know how to embed
an image right in the code).

The bitmap button flickers badly when resizing, but nothing
else does. Could someone explain what I am doing wrong?

Nothing. If you put a wx.BitmapButton on a panel with
wx.FULL_REPAINT_ON_RESIZE style it is going to flicker on Windows.
Apparently it is not being clipped in that case and the parent is drawing
over it.

So does that mean that that the following are mutually exclusive?:

1. Running on Windows
2. Gradient background
3. Able to resize the frame
4. Using wx.BitmapButtons (or, as I saw later, the generic bitmap buttons
too)
5. No flickering on resizing
6. Proper redrawing of gradient on resizing

Or could there be a way to do this?

Try adding this to your frame and calling it to put the window into
composited (double buffered) mode, supported in Windows XP and beyond:

import win32api
import win32con

   def SetCompositeMode(self, on=True):
       # get the current extended syle bits
       exstyle = win32api.GetWindowLong(self.GetHandle(),
                                        win32con.GWL_EXSTYLE)
       # adjust it
       if on:
           exstyle |= win32con.WS_EX_COMPOSITED
       else:
           exstyle &= ~win32con.WS_EX_COMPOSITED

       # put it back
       win32api.SetWindowLong(self.GetHandle(),
                              win32con.GWL_EXSTYLE,
                              exstyle)

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!