1

I'm working on my first Python and GTK script. I'm trying to do a counter/timer. The problem I have is that, while the logging function returns the proper values every second, the gtk.label is not updated. What am I doing wrong?

def startTimer(self, buttonStart):
    self.imgTimer.set_from_stock(Gtk.STOCK_YES, 2)
    self.runTimer(120)

def runTimer(self, timeout):

    for i in reversed(range(0,timeout)):

        logging.debug(i) #returns values 
        self.labelTimer.set_text(i) #doesn't do anything

        time.sleep(1)
4

1 に答える 1

3

GTK+ に更新されたラベルを描画する機会を与えません。スレッド ( PyGTK FAQを参照) を使用するか、次のようなものを使用する必要があります。

while gtk.events_pending ():
    gtk.main_iteration ()

ラベルを更新した後。

于 2012-08-18T13:08:57.837 に答える