The following code behaves differently in python 2.7.11 (after installing future
) and 3.4.4
import tkinter as tk
from tkinter import ttk
import threading
from time import sleep
def do_something_slow():
sleep(5)
progressbar.grid_remove()
app = tk.Tk()
progressbar = ttk.Progressbar(app, mode='indeterminate')
progressbar.grid()
progressbar.start()
threading.Thread(target=do_something_slow).start()
app.mainloop()
In python 3.4.4 it shows a window with a progress bar that runs for 5 seconds, then disappears, but in python 2.7.11 it shows a window with a progress bar that runs for 5 seconds, then the window becomes unresponsive
I think the reason that it goes wrong when using python 2.7 is because I shouldn't be calling tkinter widgets on a different thread (tkinter is not thread safe - I should be using queues to communicate between the threads), but then why does it work in python 3.4? Is that version thread safe?