More PyQt

Okay I am sure there is a right way to do this, and I am sure this isnt it, but this python function displays an image in a window ..... Now I need to go back to drawing board and do some reading to see how this stuff is really meant to hang together !!

def showImage(imageFile):
import PyQt4.Qt as qt
app = qt.QApplication([])
imgWin = qt.QLabel(None)
img = qt.QImage(imageFile)
imgWin.setPixmap(qt.QPixmap.fromImage(img))
imgWin.resize(img.width(), img.height())
imgWin.setWindowTitle(imageFile)
imgWin.show()
app.exec_()

showImage("C:\\tmp\\zoom.jpg")

No comments:

Post a Comment