Python OSX如何将Matplotlib窗口置于前端?
我尝试使用matplotlib进行图表可视化,但每次运行项目时都要寻找一个窗口,这非常烦人。有没有办法强迫它位于其他窗口的顶部?我使用OSX 10.8和PyCharm IDE,并且已经尝试过了Python OSX如何将Matplotlib窗口置于前端?,python,macos,matplotlib,Python,Macos,Matplotlib,我尝试使用matplotlib进行图表可视化,但每次运行项目时都要寻找一个窗口,这非常烦人。有没有办法强迫它位于其他窗口的顶部?我使用OSX 10.8和PyCharm IDE,并且已经尝试过了 from pylab import get_current_fig_manager() get_current_fig_manager().window.raise_() 这与 AttributeError: 'FigureManagerMac' object has no attribute 'win
from pylab import get_current_fig_manager()
get_current_fig_manager().window.raise_()
这与
AttributeError: 'FigureManagerMac' object has no attribute 'window'
如果还有其他想法,我将不胜感激。这在IPython对我来说很有用:
from pylab import get_current_fig_manager
fm = get_current_fig_manager()
fm.show()
不过,我还没有发现show()本身不起作用的情况 您正在调用window.raise_uqt()来自PyQT。 实际上,您可以通过这种方式升起车窗,但您需要:
- 使用
matplotlib
- 要么修复导入语句(删除括号),要么保存导入并通过图访问窗口
- 只有这样,您才能调用
window.raise()
- [cphlewis]有一个很好的答案。我发现自己经常这样做,因此我定义了一个小功能,将所有窗口弹出到表面:
def pop_all():
#bring all the figures hiding in the background to the foreground
all_figures=[manager.canvas.figure for manager in matplotlib.\
_pylab_helpers.Gcf.get_all_fig_managers()]
[fig.canvas.manager.show() for fig in all_figures]
return len(all_figures)
您在使用
show()
后正在尝试此操作?在matplotlib.use('Qt5Agg')
window = fig.canvas.manager.window
def pop_all():
#bring all the figures hiding in the background to the foreground
all_figures=[manager.canvas.figure for manager in matplotlib.\
_pylab_helpers.Gcf.get_all_fig_managers()]
[fig.canvas.manager.show() for fig in all_figures]
return len(all_figures)