CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

wait_variable() causes entire program to halt

Open Tyclonie opened this issue 2 years ago • 3 comments

Creating an IntVar and waiting for it using wait_variable on the CTk object pauses the entire program regardless image without "self.window.wait_variable(wait_variable)" allows the program to flow as usual, however adding it prevents the entire program from running

When the button is pressed it calls a lambda function which sets the value of "wait_variable" to 1

Tyclonie avatar Nov 26 '22 20:11 Tyclonie

I don't know but i hope this will work.

If you normally starting a def function, the programm will wait until the function is finished.

Also the window.mainloop() function stops until the def function is finished.

There are some ways to fix it: For example use _thread.start_new_thread()

It allows you to run functions and the main program at the same time.

Example:

import _thread

[...]

_thread.start_new_thread(load_login_window, ())

Buldes avatar Dec 04 '22 14:12 Buldes

Can you provide a full example? I never used wait_variable and I don't know why this would be useful or how this should work.

TomSchimansky avatar Dec 10 '22 13:12 TomSchimansky

If i understand correctly, the entire window pauses if a process is occurring? An easy fix for that is to use Threading pip install pythread

An example of using threading:

def convert():
   #Converts and downloads a YouTube video

thread = pythread.createThread("nameOfThread", convert, delay)

Now you can call thread.start() with a button click or something...

It works by splitting the actual app and the function into two processes.

clxakz avatar Dec 10 '22 19:12 clxakz