Cannot move Matplotlib plot window and exit it using red X button

核能气质少年 提交于 2019-12-02 04:29:47

I stumbled on a similar problem. This is because your matplotlib figure and your PyQt GUI are both running in the same main thread. Since they are in the main thread, only one of them has the CPU for itself.

I have tried to solve the problem by putting either the PyQT GUI or the matplotlib inside another thread. But that doesn't work. Both PyQT and matplotlib need to run in the main thread.

So here is a workaround. You can start the matplotlib figure from a newly created python shell:

import subprocess
...

    # When you click the button in your PyQT GUI,
    # Create a new process:
    myMatProcess = subprocess.Popen(['python', 'myGraph.py'], shell=True)

Now your PyQT GUI and the matplotlib figure you're drawing have their own python interpreter shell. And they can run smoothly without blocking each other.

If you have any further questions, don't hesitate to ask. I'd be happy to help you out.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!