pyqt如何获得以前的无花果经理

时间:2019-12-05 17:48:59

标签: python matplotlib pyqt pyqt5

我已经初始化了8个数字,如下所示;

fig = [0, 0, 0, 0, 0, 0, 0, 0]
ax_i = [0, 0, 0, 0, 0, 0, 0, 0]
ax_temp = [0, 0, 0, 0, 0, 0, 0, 0]
ax_v = [0, 0, 0, 0, 0, 0, 0, 0]
ax_fan = [0, 0, 0, 0, 0, 0, 0, 0]

fig[0], (ax_i[0], ax_temp[0], ax_v[0], ax_fan[0]) = plt.subplots(nrows = 4, ncols = 1, sharex = True)
fig[1], (ax_i[1], ax_temp[1], ax_v[1], ax_fan[1]) = plt.subplots(nrows = 4, ncols = 1, sharex = True)
fig[2], (ax_i[2], ax_temp[2], ax_v[2], ax_fan[2]) = plt.subplots(nrows = 4, ncols = 1, sharex = True)
fig[3], (ax_i[3], ax_temp[3], ax_v[3], ax_fan[3]) = plt.subplots(nrows = 4, ncols = 1, sharex = True)
fig[4], (ax_i[4], ax_temp[4], ax_v[4], ax_fan[4]) = plt.subplots(nrows = 4, ncols = 1, sharex = True)
fig[5], (ax_i[5], ax_temp[5], ax_v[5], ax_fan[5]) = plt.subplots(nrows = 4, ncols = 1, sharex = True)
fig[6], (ax_i[6], ax_temp[6], ax_v[6], ax_fan[6]) = plt.subplots(nrows = 4, ncols = 1, sharex = True)
fig[7], (ax_i[7], ax_temp[7], ax_v[7], ax_fan[7]) = plt.subplots(nrows = 4, ncols = 1, sharex = True)

当我调用单个图形时,我想在保存为.png格式之前最大化该图形。 我使用以下方法来最大化图形窗口;

manager= plt.get_current_fig_manager()
manager.window.showMaximized()

问题是,这种方法有效,并且只最大化最后一个数字,即fig [7]

fig[7], (ax_i[7], ax_temp[7], ax_v[7], ax_fan[7]) = plt.subplots(nrows = 4, ncols = 1, sharex = True)

似乎manager获得了最后一个数字的配置。 我要如何最大化先前的数字,我的意思是说有类似的东西;

manager= plt.get_fig_manager(fig[i])
manager.window.showMaximized()

或者,我想要类似的东西;

manager= plt.get_fig_manager(fig[i])

代替:

manager= plt.get_current_fig_manager()

否则,如何解决?

1 个答案:

答案 0 :(得分:1)

如果您使用的后端是PyQt,并且您想要获取所有matplotlib窗口,则可以使用topLevelWidgets()方法:

from PyQt5.QtWidgets import QApplication

for window in QApplication.topLevelWidgets():
    window.showMaximized()