Python Forum
Trouble with threading and reading variable from a different script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble with threading and reading variable from a different script
#2
tkinter is single threaded. You cannot execute tkinter code in a thread that did not call tkinter.Tk(). You can have tkinter events start threads to do work in parallel, but those threads cannot interact with tkinter widgets. For example, you cannot have a button click start a thread that appends strings to a text box.

The way to get around this restriction is use queues or some other type of signaling device to pass information from the background thread to the tkinter thread. I did this with a couple of class variables in this example:

https://python-forum.io/thread-39656-pos...#pid168425
Reply


Messages In This Thread
RE: Trouble with threading and reading variable from a different script - by deanhystad - Apr-17-2023, 02:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  trouble reading string/module from excel as a list popular_dog 0 475 Oct-04-2023, 01:07 PM
Last Post: popular_dog
  Concurrent futures threading running at same speed as non-threading billykid999 13 2,087 May-03-2023, 08:22 AM
Last Post: billykid999
Question How can I import a variable from another script without executing it ThomasFab 12 8,121 May-06-2022, 03:21 PM
Last Post: bowlofred
  Tutorials on sockets, threading and multi-threading? muzikman 2 2,195 Oct-01-2021, 08:32 PM
Last Post: muzikman
  Trouble reading files using pyexcel codebeacon 2 2,255 Feb-08-2021, 05:53 AM
Last Post: codebeacon
  Python reading variable in another py file wrongly _vertig0 2 2,034 Nov-21-2020, 07:19 AM
Last Post: _vertig0
  Trouble with reading csv file and putting it into a file Milfredo 3 2,333 Sep-04-2020, 05:30 AM
Last Post: Milfredo
  Use dynamic variable from parallel running python script Sicksym 0 1,921 May-15-2020, 02:52 PM
Last Post: Sicksym
  [split] script: remove all "carriage return" from my json variable pete 2 2,878 May-05-2020, 03:22 PM
Last Post: deanhystad
  Trouble reading Excel file. Shembeginner 2 2,364 Apr-07-2020, 04:55 AM
Last Post: Shembeginner

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020