Search code examples
pythonwxpython

Scroll bar problems


I have a scrollable wx.textcontrol widget that updates during the course of the program. Whenever the text is updated,the scrollbar resets to the top of the screen. I don't want that to happen, but I can't figure out how to stop it. Does any of you know?


Solution

  • Just keep track of the line that you are on/or has been updated and call EnsureVisible on the text control. (Also ensure you are using Append rather than Set to add new text).

    Correction, (now I have access to the help files), I was getting mixed up with MakeCellVisible from Grid controls:

    YourTextCtrl.ShowPositon(YourTextCtrl.GetLastPosition()) should do the job nicely.

    Even better if you call SetInsertionPointEnd() on your text control before the text is inserted, (by using WriteText), then your problem goes away.