0

It appears as if root.mainloop() blocks any attempt to update a textbox with text. I am trying to create a kind of status text area that will display strings of messages as I am running a python program.

top.mainloop()

chat.insert(tkinter.END, "Hello")

the insert never gets called. I know that the mainloop is blocking the call, so my question is, how does one get around this block to update the textbox with messages? The second line is a line I would like to have throughout my code (obviously with a different line of text other than Hello).

DaveK
  • 544
  • 1
  • 6
  • 16
  • 1
    Yes, `mainloop` blocks afaik. You'd have to do any additions on a separate thread if you want them to happen once you've started the app. – Carcigenicate Mar 20 '19 at 13:15
  • 1
    `mainloop` is, as the name suggests, a loop. You stay in this loop until the tkinter window is closed. In this loop, tkinter checks for events that have happened since the last loop iteration and handles these events. The main thing you need to answer is: when do you want to update the text? When the program starts? When a user interacts with the GUI? Or after a certain amount of time? You need to understand that everything that happens in tkinter is based on events. – fhdrsdg Mar 20 '19 at 13:46
  • According to my needs, I need it to happen when certain function calls are made. The window is a status window letting me know what is going on as the program is running. So I'm thinking after a certain amount of time. So running a timer that has a callback function might do it? – DaveK Mar 20 '19 at 14:47
  • 1
    @DaveK: First you have to understand [Event-driven programming](https://stackoverflow.com/a/9343402/7414759) – stovfl Mar 20 '19 at 15:38

0 Answers0