让 Pyplot windows 在 Windows 中显示为最顶层 window 7
Have Pyplot windows appear as topmost window in Windows 7
我在 Spyder 环境中使用带有 Python 2.7 的 Anaconda。绘制 pyplot 时,window 隐藏在我所有其他打开的 windows 后面,而不是出现在前面。我怎样才能让这个数字出现在所有其他打开的前面windows?
matplotlib 后端是:Qt4Agg
您可以尝试类似的方法:
fig = plt.figure()
plt.show()
fig.canvas.manager.window.activateWindow()
fig.canvas.manager.window.raise_()
但所需的行为取决于后端。
在 tkinter 上:
fm = plt.get_current_fig_manager()
#bring to front
fm.window.attributes('-topmost', 1)
#allow other windows to cover
fm.window.attributes('-topmost', 0)
(Spyder dev here) 唯一具有此功能的后端是 TkAgg
。 @valentin 在 his/her 答案中发布的代码在使用该后端时应该有效。
所有其他后端都错过了这种可能性。很长一段时间以来,这一直是 Matplotlib 的已知限制,如 Github issue.
中所示
我在 Spyder 环境中使用带有 Python 2.7 的 Anaconda。绘制 pyplot 时,window 隐藏在我所有其他打开的 windows 后面,而不是出现在前面。我怎样才能让这个数字出现在所有其他打开的前面windows?
matplotlib 后端是:Qt4Agg
您可以尝试类似的方法:
fig = plt.figure()
plt.show()
fig.canvas.manager.window.activateWindow()
fig.canvas.manager.window.raise_()
但所需的行为取决于后端。 在 tkinter 上:
fm = plt.get_current_fig_manager()
#bring to front
fm.window.attributes('-topmost', 1)
#allow other windows to cover
fm.window.attributes('-topmost', 0)
(Spyder dev here) 唯一具有此功能的后端是 TkAgg
。 @valentin 在 his/her 答案中发布的代码在使用该后端时应该有效。
所有其他后端都错过了这种可能性。很长一段时间以来,这一直是 Matplotlib 的已知限制,如 Github issue.
中所示