How to scroll to the bottom of a wxScrolledWindow

Scroll(x,y) is esentially the same as 2 additional parameters on SetScrollbars(). The problem I am having is that it doesn’t actual scroll those html windows (run the posted code with a Scroll() or 2 added params) and the scrollbar thumb changes fine, but the HTML windows begin displaying at the start of the screenspace again, so I think it is scrolling the window, but then defeating it’s purpose by displaying the html windows at the start of screen space. Perhaps SetPosition() sets the window to the scrolled windows screen space? If so, that kind of defeats the point of the virtual space of a scrolled window? Thanks, sorry for the confusion.

···

wx.ScrolledWindow.:Scroll(int x, int y) ?

2009/2/17 mario mcginley marzo@email.com

Hi, I have a list of HtmlWindows in a
wxScrolledWindow. I need the scrolled window to stay scrolled to the bottom instead of the top. I’ve tried adding two more parameters to
SetScrollbars, which sets the scrollbar thumb properly but the html
windows begin displaying at the start of the screenspace instead of the
start of the virtual space. I’ve tried
SetScrollbar,FitInside,SetVirtualSize,SetScrollbars and finally,
sending a ScrollWinEvent to scroll to the bottom all with no success.
I’m sure I must be missing something. Thanks in advance. (I’m on XP
btw).

import wx
import wx.html

class TestFrame(wx.Frame):
def init(self):

    wx.Frame.__init__(self,None,-1,"Title",size=wx.Size(300,400))
    self.scroll=wx.ScrolledWindow(self,-1)

    self.scroll.SetScrollRate(20,20)
    wx.EVT_SIZE(self.scroll, self.DoResize)
    self.HTMLWindows = []
    y=0
    for i in range(50):
        html=wx.html.HtmlWindow(self.scroll, -1, style=wx.html.HW_SCROLLBAR_NEVER)

html.SetPage(‘HELLO
WORLD %d’ % i)
y += html.GetInternalRepresentation().GetHeight()
self.HTMLWindows.append( html )

    self.scroll.SetScrollbars(0,20,0,y/20)


    evt = wx.ScrollWinEvent(wx.wxEVT_SCROLLWIN_BOTTOM)
    wx.PostEvent(self, evt)
    self.Show(1)

def DoResize(self,evt):
    y = 0
    for i in range(len(self.HTMLWindows)):

        win = self.HTMLWindows[i]
        win.SetPosition( (0,y) )
        win.SetSize( (self.scroll.GetClientSize().width,win.GetInternalRepresentation().GetHeight()) )
        y += win.GetInternalRepresentation().GetHeight()


    self.scroll.SetScrollbars(0, 20, self.GetSize().width/20, (y+19) / 20)
    evt = wx.ScrollWinEvent(wx.wxEVT_SCROLLWIN_BOTTOM)
    wx.PostEvent(self.scroll, evt)

myapp=wx.PySimpleApp()

TestFrame()
myapp.MainLoop()


Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com!


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

----- Original Message -----

From: raffaello

To: wxpython-users@lists.wxwidgets.org

Subject: Re: [wxpython-users] How to scroll to the bottom of a wxScrolledWindow

Date: Tue, 17 Feb 2009 22:11:48 +0100


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com!