简体   繁体   English

Python / Tkinter:Tkinter StringVar(IntVar等)线程安全吗?

[英]Python/Tkinter: Are Tkinter StringVar (IntVar, etc) thread safe?

Are Tkinter StringVar (IntVar, FloatVar, etc) thread safe, eg. Tkinter StringVar(IntVar,FloatVar等)线程是否安全,例如。 can a background thread read or write to these objects? 后台线程可以读取或写入这些对象吗? Or must I use a Queue to pass information between my background thread and my main Tkinter GUI thread and have my main Tkinter thread pop the Queue and update the application's StringVar's accordingly? 或者我必须使用队列在我的后台线程和我的主Tkinter GUI线程之间传递信息,让我的主Tkinter线程弹出队列并相应地更新应用程序的StringVar?

I know my application's background threads must not read or write a Tkinter widget directly but I'm unclear on whether StringVar's (or their ilk) are considered widgets or if they are objects far enough removed from widgets that they are thread safe for background threads to read and/or write. 我知道我的应用程序的后台线程不能直接读取或写入Tkinter小部件但是我不清楚StringVar(或它们的同类)是否被认为是小部件,或者它们是否是远离小部件的对象,它们对于后台线程来说是线程安全的读和/或写。

Definitely go the Queue route. 绝对是走队列路线。 Nothing in Tkinter is setup for being threadsafe :( Tkinter中没有设置为线程安全:(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM