wxNO_FULL_REPAINT_ON_RESIZE problem

Hello,

I'm having some difficulty in using the NO_FULL_REPAINT_ON_RESIZE window
style.

The code below is a working sample showing my problem. It is distilled down
from a larger program where NO_FULL_REPAINT_ON_RESIZE helps keep window
resizing smooth except for this problem. The problem is that when you resize
the frame smaller then larger you end up with artefacts from the
wxStaticText being drawn over the wxTextCtrl.

Now, I don't fully understand the interaction between
NO_FULL_REPAINT_ON_RESIZE and controls that are laid out by sizers, so one
of two things could be true:

1) This is what happens when you use NO_FULL_REPAINT_ON_RESIZE. You need to
redraw the window manually to fix things
2) This shouldn't happen. There is a bug either in my code or
wx(Python/Windows)

Does anyone know which of these is true? If it's the first one, what's the
incantation to refresh the window (since self.Refresh() doesn't do it)? If
it's the second one, any pointers to where the bug is?

Platform: wxPython 2.4.2.4u on python 2.3.2 on winXP

Many thanks,

Rich

--- Begin Code ---

import wx

class TestFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(
            self,
            None,
            -1,
            "NO_FULL_REPAINT_ON_RESIZE Test",
            style = wx.DEFAULT_FRAME_STYLE|wx.NO_FULL_REPAINT_ON_RESIZE
        )
        panel = wx.Panel(self,-1, style=wx.NO_FULL_REPAINT_ON_RESIZE)
        
        refreshButton = wx.Button(panel, -1, "Refresh")
        wx.EVT_BUTTON(panel,refreshButton.GetId(),self.OnRefresh)
        
        labelText = wx.StaticText(panel, -1,"this is some static text:")
        self.totalField = wx.TextCtrl(panel, -1)
        
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(refreshButton,0)
        sizer.Add((0,0),1)
        sizer.Add(labelText,0)
        sizer.Add(self.totalField,0)
        panel.SetSizerAndFit(sizer)
    
    def OnRefresh(self, event):
        self.Refresh()

if __name__ == "__main__":
    app = wx.PySimpleApp()
    frame = TestFrame()
    frame.Show(True)
    app.MainLoop()

--- End Code ---

------- Important Disclaimer follows -------
The information in this email and any attachments is confidential and is
solely for the attention of the addressee. It must not be disclosed to any
third party without our prior authority. Any figures or financial data are
for informational purposes only and are not intended as an offer for
purchase or sale of any security. If you are not the intended recipient,
please telephone +44 (20) 7594 4000 immediately.

Richard Cooper wrote:

Hello,

I'm having some difficulty in using the NO_FULL_REPAINT_ON_RESIZE window
style.

The code below is a working sample showing my problem. It is distilled down
from a larger program where NO_FULL_REPAINT_ON_RESIZE helps keep window
resizing smooth except for this problem. The problem is that when you resize
the frame smaller then larger you end up with artefacts from the
wxStaticText being drawn over the wxTextCtrl.

Now, I don't fully understand the interaction between
NO_FULL_REPAINT_ON_RESIZE and controls that are laid out by sizers, so one
of two things could be true:

1) This is what happens when you use NO_FULL_REPAINT_ON_RESIZE. You need to
redraw the window manually to fix things
2) This shouldn't happen. There is a bug either in my code or
wx(Python/Windows)

Does anyone know which of these is true? If it's the first one, what's the
incantation to refresh the window (since self.Refresh() doesn't do it)?

self.totalField.Refresh() is probably what you want.

If
it's the second one, any pointers to where the bug is?

It's probably just a matter of the move/refresh events happening in an odd order, so the static text ends up getting drawn over the text field after it has alread redrawn itself, and then the static text gets moved and redrawn in its new position. If you give the wx.CLIP_SIBLINGS style to the text control then it will solve it.

···

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