Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSWindow drag regions should only be invalidated on the Main Thread! This will throw an exception in the future

I am writing a Python program with two threads. One displays a GUI and the other gets input from a scanner and saves data in an online database. The code works fine on my raspberry pi but if I try it on my MacBook Pro (Catalina 10.15.2), I get the above mentioned warning followed by my code crashing.

Does anyone have an idea how to get it working or what causes the problem?

like image 387
Nothing Avatar asked Aug 14 '20 12:08

Nothing


2 Answers

You might want to call:

  matplotlib.pyplot.switch_backend('Agg') 
  • so that your server does not try to create (and then destroy) GUI windows that will never be seen.
like image 100
Daniel Moraite Avatar answered Oct 07 '22 11:10

Daniel Moraite


You likely use different Python versions. Your Python on your Raspberry PI still allows invalidating NSWindow drag regions outside the Main thread, while your Python in your MacBook Pro already stopped supporting this. You will likely need to refactor your code so that NSWindow drag regions will only be invalidated on the Main thread.

You need to localize where NSWindow drag regions are invalidated and make sure that those happen in the Main thread.

EDIT

The asker explained that according to his/her findings, NSWindow drag regions only apply to Mac.

like image 38
Lajos Arpad Avatar answered Oct 07 '22 11:10

Lajos Arpad