wxScrolledWindow.DestroyChildren() and scrollbars problem!

Hello friends,

Once again I ask for your great support and help.

My problem is that I need to rebuild the contents of a wxScrolledWindow very often on my app. But when I use DestroyChildren to clear the ScrollWin, the scrollbars just don’t appear after the rebuild of the contents.

On the following code, the scrollbars appears, as expected, on the ScrolledWindow. But when I click the button, scrollbars disappear. What’s wrong? Where’s my mistake?

I am using Mac OS X 10.3.9, wxPython 2.6.3.3 ANSI and Python 2.3.

Thank you,
Marcio Moreira

from wxPython.wx import *

COR = wxColour(243, 213, 112)

class Form1(wxWindow):
def init(self, parent, id):
wxWindow.init(self, parent, id)
label = wxStaticText(self, -1, “ScrolledWindow:”)

self.scrollwin = wxScrolledWindow(self, -1)
botao = wxButton(self, -1, “Destroy”)

···
    #
    self.ajusta_scrollwin()
    #
    sizer = wxBoxSizer(wxVERTICAL)
    sizer.Add(label, 0, 0, 0)
    sizer.Add(self.scrollwin, 0, 0, 0)
    sizer.Add(botao, 0, 0, 0)
    self.SetSizer(sizer)
    sizer.SetVirtualSizeHints(self)
    self.Layout()
    EVT_BUTTON (self, botao.GetId(), self.destruir )
     
  def

ajusta_scrollwin(self):
self.scrollwin.SetScrollRate(10, 10)
self.scrollwin.SetSize(wxSize(100,200))
self.scrollwin.SetBackgroundColour(COR)
sz_vert = wxBoxSizer(wxVERTICAL)
for x in range(50):
txt = wxStaticText(self.scrollwin, -1, "-> Line "+ str(x))
sz_vert.Add(txt, 0, 0, 0)
self.scrollwin.SetSizer(sz_vert)
sz_vert.SetVirtualSizeHints(self.scrollwin)
self.scrollwin.Layout()

  def destruir(self,

e):
self.scrollwin.DestroyChildren()
self.ajusta_scrollwin()

app = wxPySimpleApp()
frame = wxFrame(None, -1, “Where are my scrollbars?”)
Form1(frame,-1)
frame.Show(1)
app.MainLoop()


Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu celular. Registre seu aparelho agora!

Marcio Moreira wrote:

My problem is that I need to rebuild the contents of a wxScrolledWindow very often on my app. But when I use DestroyChildren to clear the ScrollWin, the scrollbars just don't appear after the rebuild of the contents.

On the following code, the scrollbars appears, as expected, on the ScrolledWindow. But when I click the button, scrollbars disappear. What's wrong? Where's my mistake?

I am using Mac OS X 10.3.9, wxPython 2.6.3.3 ANSI and Python 2.3.

On wxMac the scrollbars are not "built-in" like on the other platforms, so they are actual wxScrollBars and are considered children of the scrolled window. So when you call DestroyChildren() it is nuking the scrollbars too. So instead of using DestroyChildren you need to loop over the list returned by GetChildren and Destroy each child that is not a scrollbar.

···

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

Thank you very much Robin!
Regards from Brazil
Márcio Moreira
Robin Dunn robin@alldunn.com escreveu:

···

Marcio Moreira wrote:

My problem is that I need to rebuild the contents of a wxScrolledWindow
very often on my app. But when I use DestroyChildren to clear the
ScrollWin, the scrollbars just don’t appear after the rebuild of the
contents.

On the following code, the scrollbars appears, as expected, on the
ScrolledWindow. But when I click the button, scrollbars disappear.
What’s wrong? Where’s my mistake?

I am using Mac OS X 10.3.9, wxPython 2.6.3.3 ANSI and Python 2.3.

On wxMac the scrollbars are not “built-in” like on the other platforms,
so they are actual wxScrollBars and are considered children of the
scrolled
window. So when you call DestroyChildren() it is nuking the
scrollbars too. So instead of using DestroyChildren you need to loop
over the list returned by GetChildren and Destroy each child that is not
a scrollbar.


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


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org


O Yahoo! está de cara nova. Venha conferir!