It is not the progressbar that's causing the lockup, but your call to time.sleep()
GUI toolkits use event loops to process user input. You are interrupting event processing with the sleep call.
There are several ways to handle long-running jobs in an event-driven program;
- Chop the job up into little pieces and handle each small piece in a timeout, using the
after
method of the root window. - Handle the processing in a separate thread. Note that this thread should not call tkinter functions! And note that in cpython only one thread at a time can be processing bytecode due to the GIL.
- Handle the processing in a separate process using
multiprocessing
. Data is sent to and from that process using a Queue. The GUI program reads from the Queue and updates the GUI in a timeout.