Python Forum
[Tkinter] Tk window not displaying until loop has completed
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Tk window not displaying until loop has completed
#6
I do not understand what you are trying to do. Your example is nothing like what you claim. Are you adding images or moving images, or are you changing images to give the impression of motion? What kind of program are you writing? What are these images? Why are they moving?

If you plan to move things with a loop you are going to have a problem. As I mentioned before, GUI programs are not supposed to wait. No long for loops. To allow any kind of interaction, your program will have to break the "moving image" into "moving image in baby steps" and periodically call a function to update the image position. In tkinter this is usually done using the after() function. Using after() you call a function every 50 milliseconds or so. The function moves your image, schedules itself to run again in 50 milliseconds (using after()), and returns. Now that mainloop() is not blocked from executing, changes made in the move function quickly appear in the window.
Ganga likes this post
Reply


Messages In This Thread
RE: Tk window not displaying until loop has completed - by deanhystad - Aug-09-2021, 06:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 893 Mar-17-2024, 09:37 AM
Last Post: deanhystad
  Trying to make random image loop in Tk window using python Jediguy18 1 3,324 Dec-30-2020, 04:56 AM
Last Post: deanhystad
  Displaying various layouts in a single window arbiel 6 4,257 Nov-08-2020, 09:21 PM
Last Post: arbiel
  tkinter window and turtle window error 1885 3 6,900 Nov-02-2019, 12:18 PM
Last Post: 1885
  update a variable in parent window after closing its toplevel window gray 5 9,331 Mar-20-2017, 10:35 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020