[Tkinter-discuss] Revisiting the adage of GUI thread
Bryan Oakley
bryan.oakley at gmail.com
Mon Mar 26 18:37:45 EDT 2018
I don't know with absolute certainty, but I would say that getting/setting
variables is considered a "GUI action". Earlier I quoted Donal Fellows as
saying "you must make sure that you only ever run Tcl commands or Tkinter
operations from a single thread". Getting or setting a variable requires
running a tcl command.
On Mon, Mar 26, 2018 at 4:41 PM, Nam Nguyen via Tkinter-discuss <
tkinter-discuss at python.org> wrote:
> On this note, is setting/getting variables (StringVar, IntVar etc)
> considered GUI action? Why, or why not?
> Thanks!
> Nam
>
> On Mon, Mar 26, 2018 at 2:22 PM, Michael Lange <klappnase at web.de> wrote:
>
>> Hi,
>>
>> On Mon, 26 Mar 2018 12:54:20 -0700
>> Nam Nguyen via Tkinter-discuss <tkinter-discuss at python.org> wrote:
>>
>> > This is where my confusion comes from, actually ;). Python is single
>> > threaded (from the OS point of view). When I create the TCL
>> > interpreter, it is also created in the same thread that runs the Python
>> > interpreter. So regardless of how many Python threads (threading
>> > module), they all should belong to this same OS thread, should they not?
>>
>> I am not an expert on this, but I don't think so. At least here when I
>> run a Tkinter app using threads (on linux) I see three threads in top,
>> each with a different pid.
>> And I am quite sure that I have seen strange things happen, iirc seemingly
>> unpredictable, when the rule of thumb "run Tk only from the main thread
>> and don't touch it from any child thread" was not observed. Some times
>> such code *seemed* to work though, which I believe makes it even more
>> dangerous, since it seems you can never know what (and when) will hit you.
>> So my recommendation is to just either stick with that "rule of thumb" or
>> else try the aforementioned thread-safe tkinter version.
>>
>> Best regards
>>
>> Michael
>>
>> .-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
>>
>> On my planet, to rest is to rest -- to cease using energy. To me, it
>> is quite illogical to run up and down on green grass, using energy,
>> instead of saving it.
>> -- Spock, "Shore Leave", stardate 3025.2
>>
>
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> https://mail.python.org/mailman/listinfo/tkinter-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20180326/e872d39b/attachment-0001.html>
More information about the Tkinter-discuss
mailing list