Ticket #58 (closed defect)

Opened 8 years ago

Last modified 4 years ago

wxGTK: wxScrolledWindow in a wxNotebook has refresh problems

Reported by: robind Owned by: roebling
Priority: high Milestone:
Component: wxGTK Version:
Keywords: Cc: robind, roebling, nwmoriarty, terrelshumway, echuck, ghazel, vadz
Blocked By: Patch: no
Blocking:

Description

wxGTK 2.2.x from CVS and also the released 2.2.2
gtk+ 1.2.8 and also 1.2.6

On the 2.2 branch (I havn't tried this on the main branch yet) if you have a
wxHtmlWindow as a wxNotebook page, then partially cover the window with
another and then raise the orginial window, then the covered portion of the
wxHtmlWindow is not refreshed correctly. The background colour is the
notebook's background, not the html page's. The text is drawn correctly.

If I put a wxPanel under the wxHtmlWindow and make that the notebook
page then it refreses correctly.

Attachments

agressive_bg_colour.gif (49.7 kB) - added by robind 8 years ago.
screenshot of notebook bg colour refresh problem

Change History

Changed 8 years ago by robind

I experimented around a bit and found that a very simple wxScrolledWindow
could duplicate the bug. Here it is in Python:

class MyCanvas(wxScrolledWindow):

def init(self, parent, id = -1, size = wxDefaultSize):

wxScrolledWindow.init(self, parent, id, wxPoint(0, 0),

size, wxSUNKEN_BORDER)

self.SetBackgroundColour(wxNamedColor("WHITE"))

Make an instance of one of these be a wxNotebook page and when it gets covered
by another window, or when it scrolls then the background colour is not refreshed
properly.

Changed 8 years ago by robind

I just checked to see if maybe this has been fixed (perhaps
as a side effect of some other fix...) It's not. Now that
we can upload images I'll do so.

Changed 8 years ago by robind

screenshot of notebook bg colour refresh problem

Changed 8 years ago by robind

I've just found another example of this or a related
problem. If a wxStyleTextCtrl is a notebook page then on
wxGTK it has serious flicker problems, and large portions
of the window are refreshed when they don't need to be.

Changed 8 years ago by robind

Oops, I forgot to mention below that yet again, putting a
wxPanel under the wxStyleTextCtrl makes things work MUCH
better.

Changed 7 years ago by nwmoriarty

The same problem appears to be true for wxTreeCtrl. My simple example
work find on Windows but had similar problems to the other windows
mentioned. A wxPanel behind the wxTreeCtrl solved the problem. Fixing
this bug would greatly simplify my GUIs.

Changed 7 years ago by terrelshumway

similar/same problem with wxMSW on win2k: (wxPython 2.3.2.1
py22-hybrid) except that adding the wxPanel underneath does
not fix the problem.

See http://wxidle.sourceforge.net/bugfiles/216861.zip for
code and screen-shot.

Changed 7 years ago by robind

The problem mentioned below on MSW is a bit different and
has already been fixed for the next release.

Changed 7 years ago by robind

Robert just checked in a change which fixes this for wxGTK
as well!

Changed 7 years ago by robind

Reopening this bug since the bug showed up on a different
machine just as it was before.

Changed 6 years ago by echuck

Here's a small program that demonstrates the problem with
the background color. Scrolling and HTML aren't even required:

from wxPython.wx import *

color = wxColor(85, 170, 255)

class MyPanel(wxPanel):

def init(self, *posArgs, **kwArgs):

wxPanel.init(self, *posArgs, **kwArgs)
self.SetBackgroundColour(color)
wxStaticText(self, -1, "Hello, world.")

app = wxPySimpleApp()
frame = wxFrame(None, -1, "")

nb = wxNotebook(frame, -1)

if 1:

# put MyPanel directly in the notebook
# cannot change background color
p = MyPanel(nb, -1)
nb.AddPage(p, "foo")
p.SetBackgroundColour(color) # futile attempt to force the

issue
else:

# wrap MyPanel in an arbitrary second panel
# now background color change is respected.
p = wxPanel(nb, -1)
p2 = MyPanel(p, -1)
if 1:

# make the inner panel fill the outer
sizer = wxBoxSizer(wxHORIZONTAL)
sizer.Add(p2, 1, wxEXPAND)
p.SetSizer(sizer)

nb.AddPage(p, "foo")

frame.Show(1)
app.MainLoop()

Changed 5 years ago by ghazel

The example below has the same problem (wxGTK, even CVS
HEAD 2.5 as of 20031028 or so), and wrapping it in any
amount of sizers does not change it.

<br>from wxPython.wx import *
<br>
<br>app = wxPySimpleApp()
<br>frame = wxFrame(None, -1, "")
<br>
<br>nb = wxNotebook(frame, -1)
<br>
<br>#if 1:
<br>
<br># put MyPanel directly in the notebook
<br># cannot change background color
<br>p = wxPanel(nb, -1)
<br>
<br>text=wxTextCtrl(p, -1,
<br> "Should be white text\non black background",
<br> wxDefaultPosition,
<br> wxDefaultSize,
<br> style=wxTE_MULTILINE)
<br># futile attempt to force the issue
<br>text.SetBackgroundColour(wxBLACK)
<br>text.SetForegroundColour(wxWHITE)
<br>sizer = wxBoxSizer(wxHORIZONTAL)
<br>sizer.Add(text, 1, wxEXPAND)
<br>p.SetSizer(sizer)
<br>nb.AddPage(p, "foo")
<br>
<br>#else:
<br>
<br># wrap wxPanel in an arbitrary second panel
<br># background color change still not respected.
<br>p2 = wxPanel(nb, -1)
<br>p3 = wxPanel(p2, -1)
<br>if 1:
<br> # make the inner panel fill the outer
<br> sizer2 = wxBoxSizer(wxHORIZONTAL)
<br> sizer2.Add(p3, 1, wxEXPAND)
<br> p2.SetSizer(sizer2)
<br> text=wxTextCtrl(p3, -1,
<br> "Still should be white text\non black
background",
<br> wxDefaultPosition,
<br> wxDefaultSize,
<br> style=wxTE_MULTILINE)
<br> # futile attempt to force the issue
<br> text.SetBackgroundColour(wxBLACK)
<br> text.SetForegroundColour(wxWHITE)
<br> # make the textctrl fill the inner panel
<br> sizer3 = wxBoxSizer(wxHORIZONTAL)
<br> sizer3.Add(text, 1, wxEXPAND)
<br> p3.SetSizer(sizer3)
<br>
<br>nb.AddPage(p2, "foo2")
<br>
<br>frame.Show(1)
<br>app.MainLoop()

Changed 5 years ago by ghazel

ew- sorry about all the <br>s

Changed 5 years ago by ghazel

So I think I made a little progress towards finding another
work-around:
In most cases, calling SetBackgroundColour() after
frame.Show(true) or notebook.AddPage() (or both) allowed
the colour change to take effect.
I don't know what this implies (overwriting or maybe the
object doesn't exist yet?) but it seems significant.

Hope this helps..

Changed 4 years ago by roebling

I think this was fixed recently with the background style
changes. At least I cannot reproduce this anymore in C++.

Note: See TracTickets for help on using tickets.