I'm writing a program that will allow me to upload photos to TUMBLR via their API, I've got the uploading working (thanks to you guys).
I've put a 'queueBox' on the side of the GUI, which displays the image names, and they are stored in a QListWidget. I've put this in my Main Class' constructor:
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.setupUi(self)
self.queueBox.itemClicked.connect(self.displayPhoto)
and I have this method:
def displayPhoto(self, item):
tempName = (item.text())
print tempName
self.myLabel.setPixmap(QtGui.QPixmap(_fromUtf8(directory + '\\' + tempName)))
## self.myLabel.pixmap(QPixmap.scaled(aspectRatioMode = Qt.IgnoreAspectRatio))
## ^ ^ ^ What do I do with this? How do I set it to maintain aspect ratio?
## Currently it says ''NameError: global name 'Qt' is not defined''
This sucessfully draws the image on to myLabel which is a QLabel, however, It is very scaled, I have
self.myLabel.setScaledContents(True)
in my ui_mainWindow class, and if I turn it to False, it fixes the scaling but it only shows a small portion of the image because the image is much larger than the QLabel. What I want is to be able to maintain the aspect ratio, so it doesn't look scaled and horrible.
I found this: http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qpixmap.html and it says how to use it, however I can't get it to work as shown in the code above in my comments. Does anyone know how to use this? If so, can you provide me with an example, I've tried searching but most of the results I get are working examples in C++, not python.
Thanks!