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!