In Tkinter I made function setstatus: it appendst the input string to a list of status messages and displays the list of messages in a listbox:
root = Tk()
root.geometry("487x680")
Statusbox = Listbox(statusframe, width=75, height=5, selectmode=SINGLE)
Statusbox.grid(row=0, column=0)
root.statusmessages = [""]*10
def setstatus(statmstr):
root.statusmessages[1:] = root.statusmessages[0:-1]
root.statusmessages[0] = statmstr
Statusbox.delete(0, END) # delete listbox content
i = 0
for item in root.statusmessages:
i += 1
Statusbox.insert(END, item)
setstatus("Wait....")
do_plot() # creates a plot from matplotlib
setstatus("Plotting done.")
root.mainloop()
When running it in debug mode it works fine, all status messages appear in the listbox. Othwerwise, when running it normally, it only logs the first message ("Wait....") in the status message listbox, the 2nd message does not appear. What is the reason of it, how to solve it in Tkinter? Thanks!