Hi,
I "tried" to use Eli's sample of double buffering: draw into a temp buffer
then blit everything at once.
It's still OK on Linux and still flikers under Windows.
···
#***************************************************************
#***************************************************************
#***************************************************************
def OnPaint(self, evt):
l_pdc = wx.PaintDC(self)
try:
l_dc = wx.GCDC(l_pdc)
except:
l_dc = l_pdc
(l_w, l_h) = self.GetSize()
l_tmp = wx.EmptyBitmap(l_w, l_h)
l_mdc = wx.MemoryDC()
l_mdc.SelectObject(l_tmp)
self.Redraw_Background(l_mdc)
self.Redraw_Text(l_mdc)
self.refresh_text = True
self.Redraw_Buttons(l_mdc)
l_dc.Blit(0, 0, l_w, l_h, l_mdc, 0, 0)
l_mdc.SelectObject(wx.NullBitmap)
Any clue ?
Thanks
--
_________________________
Philippe C. Martin
www.snakecard.com
_________________________
There’s more to it than
that. You have to disable the EVT_ERASE_BACKGROUND event as well.
Painting (at least on
Windows) is done with two events - the first one paints over the
windows with its background color and the seconds one actually paints
what should be on it. If both events are handled it creates flicker, no
matter what else you do.
The reason for double
buffering in my code wasn’t to prevent flicker. It was to make sure the
entire rect of the window is actually painted over with something and
the easiest (though maybe not the fastest) way to do that is create an
EmptyBitmap the size of the window, draw on it and Blit it to the
screen.
Philippe C. Martin
wrote:
···
Hi,
I "tried" to use Eli's sample of double buffering: draw into a temp buffer then blit everything at once.
It's still OK on Linux and still flikers under Windows.
#***************************************************************
#***************************************************************
#***************************************************************
def OnPaint(self, evt):
l_pdc = wx.PaintDC(self)
try:
l_dc = wx.GCDC(l_pdc)
except:
l_dc = l_pdc
(l_w, l_h) = self.GetSize()
l_tmp = wx.EmptyBitmap(l_w, l_h)
l_mdc = wx.MemoryDC()
l_mdc.SelectObject(l_tmp)
self.Redraw_Background(l_mdc)
self.Redraw_Text(l_mdc)
self.refresh_text = True
self.Redraw_Buttons(l_mdc)
l_dc.Blit(0, 0, l_w, l_h, l_mdc, 0, 0)
l_mdc.SelectObject(wx.NullBitmap)
Any clue ?
Thanks
That sure did it Eli, thanks !
Regards,
Philippe
···
On Friday 26 January 2007 14:05, Eli Golovinsky wrote:
There's more to it than that. You have to disable the EVT_ERASE_BACKGROUND
event as well. Painting (at least on Windows) is done with two events - the
first one paints over the windows with its background color and the seconds
one actually paints what should be on it. If both events are handled it
creates flicker, no matter what else you do.
The reason for double buffering in my code wasn't to prevent flicker. It
was to make sure the entire rect of the window is actually painted over
with something and the easiest (though maybe not the fastest) way to do
that is create an EmptyBitmap the size of the window, draw on it and Blit
it to the screen.
Philippe C. Martin wrote:
Hi,
I "tried" to use Eli's sample of double buffering: draw into a temp buffer
then blit everything at once.
It's still OK on Linux and still flikers under Windows.
#***************************************************************
#***************************************************************
#***************************************************************
def OnPaint(self, evt):
l_pdc = wx.PaintDC(self)
try:
l_dc = wx.GCDC(l_pdc)
except:
l_dc = l_pdc
(l_w, l_h) = self.GetSize()
l_tmp = wx.EmptyBitmap(l_w, l_h)
l_mdc = wx.MemoryDC()
l_mdc.SelectObject(l_tmp)
self.Redraw_Background(l_mdc)
self.Redraw_Text(l_mdc)
self.refresh_text = True
self.Redraw_Buttons(l_mdc)
l_dc.Blit(0, 0, l_w, l_h, l_mdc, 0, 0)
l_mdc.SelectObject(wx.NullBitmap)
Any clue ?
Thanks
--------------------------------------------------------------------- To
unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org For
additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
--
_________________________
Philippe C. Martin
www.snakecard.com
_________________________
Eli Golovinsky wrote:
The reason for double buffering in my code wasn't to prevent flicker. It was to make sure the entire rect of the window is actually painted over with something and the easiest (though maybe not the fastest) way to do that is create an EmptyBitmap the size of the window, draw on it and Blit it to the screen.
Another reason to Double buffer is to keep form having to re-draw everything every time the window needs updating. To accomplish that, you need to keep the bitmap around, and only re-draw it when it needs to change. Your Paint handler then only needs to blit the bitmap to the screen.
see:
http://wiki.wxpython.org/index.cgi/DoubleBufferedDrawing
-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
Chris.Barker@noaa.gov