[Pyobjc-dev] textview scrolling
Brought to you by:
ronaldoussoren
From: Joshua K. <jo...@ro...> - 2004-10-21 22:51:45
|
Interesting one for ya. I've got a NSTextView that I'm trying to scroll to the bottom programatically, and it works, but its hokey. The situation is I've got a separate thread throwing data into a queue. Now to access this data from the main (Cocoa) thread, I have and NSTimer set up to poll that queue. Here's the routine: def checkOutput(self, sender): y = self.outputView.frame().size.height self.outputView.scrollPoint_(NSPoint(0,y)) try: while 1: message = self.queue.get(0) txt = NSAttributedString.alloc().initWithString_( message.data) self.outputView.textStorage().appendAttributedString_(txt) except: pass The issue I was having is that if I try to scroll immediately after appending the string to the text storage object, it doesn't update the geometry of the view. I assume the view will not update its geometry until it gets its own time after this function exits. So you see, this function works, but there is a small lag due to the fact that this function is called every 0.1 seconds. Any suggestions for a better way to handle this? |