0

I am beginning a python project that will integrate into an existing project and would like some feedback as to if I am approaching this at a high level correctly. The existing main python thread of the overarching environment is and will remain available for command line entry at all times, thus it is not periodic in nature.

I will need to continually process unsolicited messages from a server that are sent over a socket. Some of the values extracted from messages I would like to display real time in a GUI to the user, and additionally be accessible from the command line (main thread). I have just begun to learn of tkinter and would leverage it for the GUI portion.

Here are my assumptions:

1.) I will need a unique threads for both the message processor and the GUI since the main thread cannot be used, as it is reserved for command line access.

2.) I will need to access variables set by the message processor from both the Main Command line thread and the GUI thread. From what Ive read so far, I should do this in a queue to make it thread safe???

Am I on the right path from a high level perspective??

theeld
  • 1
  • I doubt if you can run tkInter in a secondary thread. See https://stackoverflow.com/questions/3567238/threaded-tkinter-script-crashes-when-creating-the-second-toplevel-widget. Your approach to the project depends on whether you can figure out how to do this. BTW, setting a variable in thread B and accessing it in thread A is safe. It's when two threads try to modify the same variable that trouble occurs. – Paul Cornelius Jul 08 '17 at 02:13
  • I think tkinter works fine in a secondary thread. It's just that _all_ tkinter code needs to be in the same thread. – Bryan Oakley Jul 08 '17 at 14:40

0 Answers0