[wxPython] wxScrolledWindow

I've been looking at wxScrolledWindow for two days now, and I still can't seem to figure it out.

from wxPython.wx import *

class App(wxApp):
  def OnInit(self):
    self.frame = TestFrame()
    self.frame.Show(true)
    self.SetTopWindow(self.frame)
    return true

class TestFrame(wxFrame):
  def __init__(self):
    wxFrame.__init__(
      self, NULL, -1, 'Test Frame', wxDefaultPosition, wxSize(400, 400)
    )
    self.text = []
    for i in range(0, 100):
      self.text.append(' ' * (i / 10) + str(i))
    self.textWindow = TextWindow(self, self.text)

class TextWindow(wxScrolledWindow):
  def __init__(self, parent, text):
    wxScrolledWindow.__init__(self, parent, -1)
    self.text = text
       self.SetScrollbar(wxVERTICAL, 0, 60, 30)
    self.SetTargetWindow(self)
    EVT_PAINT(self, self.onPaint)
   def onPaint(self, event):
    dc = wxPaintDC(self) self.PrepareDC(dc) for i in range(0, len(self.text)):
      dc.DrawText(self.text[i], 10, i * 20 + 10)

a = App()
a.MainLoop()

I absolutely can not understand why this code doesn't scroll. Can someone please enlighten me?
All I want is a window that scrolls text... I can get the text, and the window with scrollbars,
but the text refuses to budge... :frowning:

  Thanks in advance,
    Jp Calderone

···

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

I absolutely can not understand why this code doesn't scroll. Can
someone please enlighten me?

You need to use self.SetScrollbars instead of self.SetScrollbar:

from wxPython.wx import *

class App(wxApp):
  def OnInit(self):
    self.frame = TestFrame()
    self.frame.Show(true)
    self.SetTopWindow(self.frame)
    return true

class TestFrame(wxFrame):
  def __init__(self):
    wxFrame.__init__(
      self, NULL, -1, 'Test Frame', wxDefaultPosition, wxSize(400, 400)
    )
    self.text =
    for i in range(0, 100):
      self.text.append(' ' * (i / 10) + str(i))
    self.textWindow = TextWindow(self, self.text)

class TextWindow(wxScrolledWindow):
  def __init__(self, parent, text):
    wxScrolledWindow.__init__(self, parent, -1)
    self.text = text

    self.SetScrollbars(0, 10, 0, 200)

    EVT_PAINT(self, self.onPaint)

  def onPaint(self, event):
    dc = wxPaintDC(self)
    self.PrepareDC(dc)
    for i in range(0, len(self.text)):
      dc.DrawText(self.text[i], 10, i * 20 + 10)

a = App()
a.MainLoop()

···

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