MCPcopy Create free account
hub / github.com/ActiveState/code / ProgressThread

Class ProgressThread

recipes/Python/576705_pyGTK_threading/recipe-576705.py:35–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 gtk.main_quit()
34
35class 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
63if __name__ == "__main__":
64 pyapp = PyApp()

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected