Domanda

I want to modify the text of some Labels in my PyGTK application just before beginning a time-consuming operation (loading several megabytes of text into a TextBuffer). But when I try to do this, the Label updates don't happen until after the TextBuffer has started loading the file (text appears in the viewer), which takes several seconds during which the program appears to have frozen. For the sake of my users, I'd like to display these message before I start loading the file, in the same order my code is written. How can I do this? Is there a way to have my program wait for the execution of events that are pending in gobject's main loop? (Which is where I assume calls to gtk.Label.set_text go)

È stato utile?

Soluzione

This forces the refresh of the screen :

##  force the refresh of the screen
            while gtk.events_pending():
                gtk.main_iteration()
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top