I have a button that I want to press to process some excel data. This often takes a moment or two especially if the user uploads a number of large files.
While the files are being processed, I want to display a note to the user that the files are processing and that the program has not frozen. Once the files are complete, I want to indicate that as well.
This is the relevant code I have so far:
self.l2 = Label(self, text = " ", width = 20)
self.l2.grid(row = 3, column = 2, sticky = W)
# Calculate button
self.b2 = Button(self, text = "Calculate", command = self.calculate, width = 20)
self.b2.grid(row = 3, column = 3, sticky = W)
In order for the screen to refresh, the event loop must be able to process a refresh event. Since your code is running, the event loop is frozen.
A quick and dirty solution is to call
self.update_idletasks(), which tells tkinter to handle all of the "idle" events, which includes events related to updating the screen.
self.l2.config(text="Processing...") self.update_idletasks() get_data(filelist, self.v.get()) self.l2.config(text="Files Ready!")