簡體   English   中英

Python Tkinter selenium chromedriver多線程錯誤

[英]Python Tkinter selenium chromedriver multithreading error

function 在沒有多線程的情況下運行良好,但是當我使用此代碼時

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

而不是這個

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

我收到這個錯誤

線程中的異常線程 Thread-1Thread-2 中的異常::Traceback(最近一次調用最后一次):Traceback(最近一次調用最后一次):文件“C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\ lib\threading.py",第 932 行,在 _bootstrap_inner 文件中 "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\threading.py",第 932 行,在 _bootstrap_inner self.run()自我運行()

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

請注意,tkinter 確實支持多線程。 所以如果click1操作 GUI,你會得到錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM