window freezes after clicking of button in python gtk3

Solutions on MaxInterview for window freezes after clicking of button in python gtk3 by the best coders in the world

showing results for - "window freezes after clicking of button in python gtk3"
Bowen
08 Jan 2017
1import threading
2
3def on_next2_clicked(self,button):
4    def my_thread(obj):
5        cmd = "My Command"
6        proc = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE)
7        while True:
8                line = proc.stdout.read(2)
9                if not line:
10                    break
11                obj.fper = float(line)/100.0
12                obj.ui.progressbar1.set_fraction(obj.fper)
13        print "Done"
14
15    threading.Thread(target=my_thread, args=(self,)).start()