【问题标题】:pyqt how to get previous fig managerpyqt如何获得以前的无花果管理器
【发布时间】:2020-03-30 17:05:52
【问题描述】:

我初始化了 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()

问题是,这种方法有效并且只最大化最后一个图,即图[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()

否则,我该如何解决?

【问题讨论】:

    标签: python matplotlib pyqt pyqt5


    【解决方案1】:

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

    from PyQt5.QtWidgets import QApplication
    
    for window in QApplication.topLevelWidgets():
        window.showMaximized()
    

    【讨论】:

    • 感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-19
    • 1970-01-01
    • 2015-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多