[pygtk] A Timer and refreshing TextView

Mark Stahler isignupnow at gmail.com
Mon Dec 3 08:12:56 WST 2007


Hello,

I am attempting to have a textview tail the end of a log file. So far I 
can load the log and scroll to the end however I am running into a 
problem have the log file refresh.

Code:

        textview = self.gui.get_widget("bottom_textview")
       
        # Methods that need to be run on start
        self.refreshLog()
       
        # Timer to autorefresh log
        timer = threading.Timer(10, self.refreshLog)
        timer.start()

    def refreshLog(self):
        file = open('log.txt')
        string = file.read()
       
        buffer = textview.get_buffer()
        buffer.set_text(string)
         
        mark = buffer.create_mark("end", buffer.get_end_iter())
        textview.scroll_to_mark(mark, 0)
        buffer.delete_mark_by_name("end")

The code seems to run ok but the text in the TextView does not update. I 
loaded the log into vi and appended some text and saved it but the 
program would not reload it. Am I overlooking something simple? Is there 
another way to do the timer? Thanks for the help!

Mark


More information about the pygtk mailing list