0

the function works well without multithreading, but when i use this code

button1 = ttk.Button(root, text='btn1', width=3.3, command=threading.Thread(target=click1).start())

instead of this

button1 = ttk.Button(root, text='btn1', width=3.3, command=click1)

I get this error

Exception in thread Exception in thread Thread-1Thread-2: : Traceback (most recent call last): Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 932, in _bootstrap_inner File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 932, in _bootstrap_inner self.run()self.run()

1 Answer 1

1
thrd = threading.Thread(target=click1)
button = ttk.Button(root, text='btn1', width=3.3, command=thrd.start) # Do not call start here

Note that tkinter does support multithreading. So if click1 manipulates the GUI, you will get errors.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.