gpt4 book ai didi

python - 属性错误: 'FigureManagerBase' object has no attribut 'window'

转载 作者:太空宇宙 更新时间:2023-11-03 19:44:57 25 4
gpt4 key购买 nike

我已经很好地使用了下面的 python 代码,但是当我重新安装 Anaconda python 2.7 版本时,该代码出现错误。为什么会发生这种情况?

plt.subplots_adjust(top=0.9, bottom=0.05, left=0.05, right=0.95, wspace=0.55, hspace=0.2)
plt.figtext(0.5, 0.95, str(os.path.basename(self.filepath)),ha='center', color='black', weight='bold', size='small')
mngr = plt.get_current_fig_manager()
mngr.window.setGeometry(810, 30, 800, 800)
show()
<小时/>
Traceback (most recent call last):

File "C:\Users\hyeyoung\Desktop\20200211MHyeyoung.py", line 4482, in onOpenImageFile
self.ShowAFewFrames()

File "C:\Users\hyeyoung\Desktop\20200211MHyeyoung.py", line 4509, in ShowAFewFrames
mngr.window.setGeometry(810,30,800, 800)

AttributeError: 'FigureManagerBase' object has no attribute 'window'

--------------------------------------------------------------------------

Anaconda python ver. : 2.7
matplotlib ver. :2.2.2

please give me an answer. thx

最佳答案

您假设 plt.get_current_fig_manager() 返回一个具有 window 属性的对象。只有使用 Qt4AggQt5Agg(或 Qt4Cairo/Qt5Cairo)后端时才会出现这种情况,因为在这种情况下,图形管理器是一个 FigureManagerQT,它是 QtWidgets.QWidget 的子类,并且 Qt 小部件具有 window 属性。

因此,如果您想使用该属性,请确保使用相应的后端,例如

matplotlib.use("Qt5Agg")

关于python - 属性错误: 'FigureManagerBase' object has no attribut 'window' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60199720/

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