| 33 | gtk.main_quit() |
| 34 | |
| 35 | class ProgressThread(threading.Thread): |
| 36 | def __init__(self, progressbar, step_value): |
| 37 | threading.Thread.__init__ (self) |
| 38 | |
| 39 | self.pb = progressbar |
| 40 | self.step = step_value |
| 41 | |
| 42 | self.stopthread = threading.Event() |
| 43 | |
| 44 | def run(self): |
| 45 | while not self.stopthread.isSet(): |
| 46 | cur_frac = self.pb.get_fraction() |
| 47 | new_frac = cur_frac + self.step |
| 48 | if new_frac > 1.0: |
| 49 | new_frac = 1.0 |
| 50 | |
| 51 | gtk.gdk.threads_enter() |
| 52 | self.pb.set_fraction(new_frac) |
| 53 | gtk.gdk.threads_leave() |
| 54 | |
| 55 | if self.pb.get_fraction() == 1.0: |
| 56 | break |
| 57 | |
| 58 | time.sleep(0.1) |
| 59 | |
| 60 | def stop(self): |
| 61 | self.stopthread.set() |
| 62 | |
| 63 | if __name__ == "__main__": |
| 64 | pyapp = PyApp() |