Pmw.ScrolledText programatically scrolling
grahamd at dscpl.com.au
Sun Sep 15 09:06:36 CEST 2002
Joe Connellan <joec at mill.co.uk> wrote in message news:<3D81D44E.C5FC4A8B at mill.co.uk>...
> I've got a Pmw.ScrolledText() that I'm using as a log and I've written
> an addToLog() method like so:
> def addToLog(self, logString):
> self.logScr.configure(text_state = 'normal')
> self.logScr.insert(END, logString)
> self.logScr.configure(text_state = 'disabled')
> I now want it to scroll when I add a line so the user doesn't have to
> constantly scroll down to view the most recent lines.
> I can't find any info on doing this with ScrolledText or its text
> component - do I need to reposition the scrollbars for it to scroll?
Another slightly different way to what others have suggested is the
self._eventView = Pmw.ScrolledText(g1.interior(),text_padx=4,
p1,p2 = self._eventView.yview()
if (p1 == 0.0 and p2 == 0.0) or p2 == 1.0:
A trick in this code is that one uses yview() to determine what of the
text is being shown and will only move to last text inserted if the scroll
area was already at the end.
The reason for this is that it can be mighty annoying to have the scrolled
area always go to the end if you have used the scroll bar to explicitly
go to an earlier part of the text to look at it.
More information about the Python-list