gpt4 book ai didi

python - pyqt如何获取以前的无花果管理器

转载 作者:行者123 更新时间:2023-12-01 06:46:32 25 4
gpt4 key购买 nike

我初始化了 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= plt.get_fig_manager(fig[i])
manager.window.showMaximized()

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

manager= plt.get_fig_manager(fig[i])

而不是:

manager= plt.get_current_fig_manager()

否则,我该如何修复它?

最佳答案

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

from PyQt5.QtWidgets import QApplication

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

关于python - pyqt如何获取以前的无花果管理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59200695/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com