在Python中引用其他包中的图像
在我的项目中,我使用了这种机制在Python中引用其他包中的图像,python,pyqt,Python,Pyqt,在我的项目中,我使用了这种机制 view/ __init__.py forms/ __init__.py someFile.py images/ __init__.py someImage.png 我尝试在someFile.py中显示图像以引用someImage.png。我尝试了以下几种: self.label_8.setPixmap(QtGui.QPixmap(_fromUtf8("/view/images/someImag
view/
__init__.py
forms/
__init__.py
someFile.py
images/
__init__.py
someImage.png
我尝试在someFile.py中显示图像以引用someImage.png。我尝试了以下几种:
self.label_8.setPixmap(QtGui.QPixmap(_fromUtf8("/view/images/someImage.png")))
self.label_8.setPixmap(QtGui.QPixmap(_fromUtf8("view/images/someImage.png")))
self.label_8.setPixmap(QtGui.QPixmap(_fromUtf8("images/someImage.png")))
self.label_8.setPixmap(QtGui.QPixmap(_fromUtf8("someImage.png")))
但我无法显示图像。我怎样才能解决这个问题 这个问题看起来可以用下面的答案来解决:看起来你需要相对路径<代码>。指向父目录。问题就像@dpwilson说的是相对路径。。要点。我修好了。再次感谢你