我无法在GUI-PyQt4中上传图片。它无法在label_97中写入图像。 请帮忙解决这个问题。
def uploadsignsCheck(self):
fileName = QtGui.QFileDialog.getOpenFileName(self.label_97, 'Open File',"/usr/tmp","Images (*.png *.jpg *.jpeg *.bmp *.gif)")
fname = image.open(fileName)
data = fname.read()
self.label_97.setpixmap(data)
self.label_97.fname.write(data)
fname.close()
print(" pushButton_3 Clicked !")
答案 0 :(得分:1)
您需要在setPixmap中输入图像的路径,无需将图像数据写入其中。
def uploadsignsCheck(self):
fileName = QtGui.QFileDialog.getOpenFileName(self.label_97, 'Open File',"/usr/tmp","Images (*.png *.jpg *.jpeg *.bmp *.gif)")
self.label_97.setPixmap(fileName) # path goes here
print(" pushButton_3 Clicked !")