Note that there are some explanatory texts on larger screens.

plurals
  1. POQPixmap maintain aspect ratio
    primarykey
    data
    text
    <p>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).</p> <p>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:</p> <pre><code>def __init__(self): QtGui.QMainWindow.__init__(self) self.setupUi(self) self.queueBox.itemClicked.connect(self.displayPhoto) </code></pre> <p>and I have this method:</p> <pre><code>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'' </code></pre> <p>This sucessfully draws the image on to myLabel which is a QLabel, however, It is very scaled, I have</p> <pre><code>self.myLabel.setScaledContents(True) </code></pre> <p>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.</p> <p>I found this: <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qpixmap.html" rel="nofollow noreferrer">http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qpixmap.html</a> 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.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload