Studying python 3 (and tkinter ), you need to implement the following thought:
you need to display a picture or some inscription in the window while I have some calculations for some time, then you need to close this window. Example:

from tkinter import * root = Tk() Label(text='Please wait').pack() # здесь выполняется некий цикл от 5 до 30 сек ... root.mainloop() 

Tell me how to do it right!

    2 answers 2

    The easiest way to use multithreading:

     import time from threading import Thread from tkinter import Tk, Label, Button root = Tk() label = Label(root, text='Ничего не происходит') label.pack() def long_calculation(seconds): label.config(text='Ждём...') time.sleep(seconds) label.config(text='Дождались!') def start_thread(): thread = Thread(target=long_calculation, args=(5,)) thread.start() b = Button(root, text='Запуск', command=start_thread) b.pack() root.mainloop() 
    • Tkinter, like most GUI libraries, is not thread-safe, so calling label.config() on a thread is a very bad idea. - Sergey Gornostaev
    • @SergeyGornostaev, for example. He also needs to make some calculations, and this is not necessarily related to editing widgets. - Helow19274
    • I, apparently not enough explained his Wishlist. While the program is looking for a file on the computer, the window should say “Zhdems”, after the file is found, the first window should close and open the main window for further work (with this file). - Evgen Litvinov
    • Or all this can happen in one window, just the inscription disappears after the search - it does not matter. I'm not really friends with tkinter)) - Evgen Litvinov

    It turns out that instead of .mainloop () you need to use .update () .

     from tkinter import * root = Tk() Label(text='Please wait').pack() root.update() # здесь выполняется некий цикл от 5 до 30 сек ... root.destroy() 

    The window after the cycle closes and the program goes on as usual