我已经很好地使用了下面的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
属性的对象。只有在使用Qt4Agg
或Qt5Agg
(或Qt4Cairo
/Qt5Cairo
)后端时才会出现这种情况,因为在这种情况下,图形管理器是FigureManagerQT
,它是QtWidgets.QWidget
的子类,而Qt小部件具有window
属性因此,如果要使用该属性,请确保使用相应的后端,例如
相关问题 更多 >
编程相关推荐