[PyKDE] Scrolling Log Windows?

dan at tombstonezero.net dan at tombstonezero.net
Sun Feb 8 18:29:01 GMT 2004


Hi,

I know it's bad form to follow up my own post, but now that I've
received two private (and extremely useful) replies and fixed the
problem, it's about time to summarize.  Thank you Roberto and
Phil.

On Sat, 7 Feb 2004 10:10:50 -0500,
dan at tombstonezero.net wrote:

> How do I get my log windows to scroll?  I have a QTextEdit
> widget in LogText mode, and I can write to it just fine.  The
> problem is that the window continues to show the first few lines
> of the text instead of scrolling as I append more text to it.
> The scrollbar works well enough, but I'd like to control it from
> my program.

Obviously (of course, now that I know the answer), the solution is
QTextEdit's scrollToBottom method.  Turns out that my program
contained a bug (imagine that... :-/) preventing any solution from
so much as getting a chance (details elided):

    def setuplogwindow( self ):
        self.logwindow = QTextEdit( self )
        backend.install_hook_function( self.logwindow.append )

    def update_hook( self, text ):
        self.logwindow.append( text )
        self.logwindow.scrollToBottom( )

Oops.  I added update_hook later in the development process (when
I discovered that the window didn't scroll to the bottom all by
itself) and evidently didn't quite finish.  You can be sure that
it won't happen again (today, anyway, maybe).

On Sun, 8 Feb 2004 06:46:44 -0800 (PST),
stuff at mailzilla.net wrote:

> Also, you may need to conditionally block the signal as
> necessary (if for example you wish to scroll back up as new text
> is appended-- obviously, you wouldn't want the widget to jump to
> the bottom while you were trying to read a log entry in the
> middle, etc...)

Thanks for the hint; I'll keep that in mind.  This particular log
window only grows in direct response to a user action, so that'd
be overkill in this case.

Regards,
Dan

-- 
I hear, and I forget.                                  Dan Sommers
I see, and I remember.                 [insert your own joke here]
I do, and I understand.             <mailto:dan at tombstonezero.net>
            -- Confucius       <http://www.tombstonezero.net/dan/>




More information about the PyQt mailing list