开发者

GTK Progressbar pulsing python

开发者_运维百科

How can I get a Progressbar to "pulse" while another function is run?


There is an example of how to do this here.


Push that another function into a separate thread. As long as your main thread runs any code, GUI is frozen. This is not a problem for short code pieces, but obviously a problem in your case.

Also read what PyGTK FAQ has to say about using threads in PyGTK program.


If your function runs in many iterations that don't take too long by themselves, then you don't necessarily need to mess around with separate threads. You can also cause the GUI to update itself during your long calculation:

def long_function(some_args):
    while task_is_not_finished():
        do_some_stuff_that_doesnt_take_too_long()
        progress_bar.pulse()
        while gtk.events_pending():
            gtk.main_iteration()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜