python:: howto apply Thread() at command _ tkinter

 

 

이전에는 Thread.start()를 적용하려고 별도로 Function()을 구현했는데,

command에서 바로 Thread처리하는 것이 더 간편함

 

 

** 그럼 command에서 변수 사용할 때 lambda 함수 사용해야 하니, lambda && thread 같이 사용하는 것도 테스트를 해봐야 하나...

 

# example1 
import tkinter from ttk 
import time 

def myFunction():
	time.sleep(5)  	#5초간 멈춤

btn1 = ttk.Button(root, text="Button1", command=myFunction) 


# using Thread
btn2 = ttk.Button(root, text="Button2", command=Threading.Thread(target=myFunction).start())

 

 

https://www.youtube.com/watch?v=jnrCpA1xJPQ&list=PLCC34OHNcOtoC6GglhF3ncJ5rLwQrLGnV&index=98 

 

반응형