Question

I am working on a chatroom client and am using an HTML window to process things like images and html tags and formatting. I am having trouble finding out how to make the scrollbar stay at the bottom as messages are added to the window (every message sends the bar to the top)

would anyone know how I would go about doing this?

Was it helpful?

Solution

After you add a new message, you can call Scroll on your htmlWindow to set its scrollBar position to the end.

yourHtmlWindow.Scroll(-1, self.GetClientSize()[0])

If you want your scrollBar to stay at the bottom when the window is resized then you will need to Bind to wx.EVT_SIZE so that you can call Scroll on resize.

def onSize(self, event):
    event.Skip()
    wx.CallAfter(yourHtmlWindow.Scroll, -1, self.GetClientSize()[0])
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top