scrollbar artifacts with wx.BG_STYLE_PAINT

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

scrollbar artifacts with wx.BG_STYLE_PAINT

itsayellow
Hi All,

I have a question for the best way to deal with a problem, or perhaps whether the problem I'm finding is a bug.

I've been trying to make my wxpython app be cross-platform, and The Flicker Problem with Windows is considerable.  The advice on solving it seems to indicate that one should do the following:
self.SetBackgroundStyle(wx.BG_STYLE_PAINT)


My app draws to the whole window (it's a graphical application) so that's actually no problem for me.

Except for one place: the corner between the horizontal and vertical scrollbars.

It's not part of the Client Area, so I'm never drawing to it.  But if I change the size of my virtual area, so that before I have one scrollbar and afterwards I have two scrollbars, then I can get a chopped off part of a scrollbar leftover in the corner.  My app zooms in and out of an image, so I do change the virtual area.

My question: Is there a best practice to avoid this situation when you're not auto-erasing the background?  I see it in macOS (see images below) and also in Windows.

thanks!
Matt

Sample code which displays the behavior:
#!/usr/bin/env python3

import wx

class MyCanvas(wx.ScrolledCanvas):
   
def __init__(self, parent, id=wx.ID_ANY):
       
super().__init__(parent, id)

       
# attempting to avoid Windows flicker
       
# THIS IS WHAT CAUSES THE SCROLLBAR ARTIFACT
       
#   if this line is absent, scrollbar corner is erased fine
       
self.SetBackgroundStyle(wx.BG_STYLE_PAINT)

       
# x smaller than MainWindow, y larger than MainWindow
       
self.SetVirtualSize(600, 1000)
       
self.SetScrollRate(10,10)

       
# scroll so vert. scrollbar is at bottom
       
self.Scroll(0, 2000)

        wx
.CallLater(
               
1000,
               
self.zoom_scroll,
               
)
   
def zoom_scroll(self):
       
# x larger than MainWindow, y larger than MainWindow
       
self.SetVirtualSize(1000, 1200)
       
# scroll so vert. scrollbar is at bottom
       
self.Scroll(0, 2000)

class MainWindow(wx.Frame):
   
def __init__(self, *args, **kwargs):
       
super().__init__(*args, **kwargs)
       
self.my_canvas = MyCanvas(self)
       
self.SetSize((800, 600))
       
self.Show(True)

def main():
    my_app
= wx.App()
    main_win
= MainWindow(None)
    my_app
.MainLoop()

if __name__ == '__main__':
    main
()




before enlargement of Virtual Area:



















after enlargement of Virtual Area:



--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.