Hi, I'm developing an application in Windows, and I got a report from
a Mac user that scroll bars were missing from a
wx.lib.scrolledPanel.scrolledPanel. I don't have a Mac handy, but we
were able to seemingly track the problem to a call to
scrolledPanel.DestroyChildren. (I repopulate the panel repeatedly with
a bunch of controls as the user navigates around).
On Windows, this works fine; even after destroying all the children on
the panel, scroll bars appear "as needed." On the Mac, the initial
call works fine (scroll bars appear as needed), but once
DestroyChildren has been called and the panel repopulated, no scroll
bars will appear in the panel at all.
Is this a known issue? I can provide code if it's necessary.
I'm using python 2.5.0 and wxPython 2.8.9.2. The Mac user is using
python 2.5.1 and I don't know offhand what version of wxpython.
The widgets aren't being destroyed as the user scrolls; there are
other buttons that the user presses to "navigate" through a very large
and complicated "tree" of possibilities. Each one of the possibilities
(there are around 8^10 different "scenarios") has its own grid of
information to be displayed and the grids are of different shapes and
sizes.
In any event, I was able to figure out how to solve the problem; it
seems that the scroll bars are just handled differently on the Mac and
in Windows.
typelist = [type(x) for x in self.mainPanel.GetChildren()]
typedict = {}
for x in typelist:
typedict = 1
print typedict.keys()
Using code like the above, I found (for the same test case):
On Windows:
[<class 'wx._controls.StaticText'>, <class 'hgrid.HandGridButton'>,
<class '__main__.NavButton'>]
On Mac:
[<class 'wx._controls.StaticText'>, <class 'wx._controls.ScrollBar'>,
<class 'hgrid.HandGridButton'>, <class '__main__.NavButton'>]
So instead of calling DestroyChildren(), which was deleteing the
scrollbars as well I'm just using:
for child in self.mainPanel.GetChildren():
if type(child) != wx._controls.ScrollBar:
child.Destroy()
which does just what I need for now. In the future I think I can
improve things further by precreating the various gridstyles, making
them invisible, and then updating the data to be displayed and showing
the right one as the user navigates.
Thanks!
Jerrod
···
On Aug 30, 9:05 am, Mike Driscoll <m...@pythonlibrary.org> wrote:
Hi Jerrod,
Why are you destroying and creating the widgets as the user scrolls? That
sounds problematic to me. Maybe if you explain your use case, we can help
you figure it out. Better yet, can you create a sample app that demonstrates
the issue? Seehttp://wiki.wxpython.org/MakingSampleApps