python - Bug when drawing a QImage on a widget with PIL and PyQt -


I'm trying to write a small graphic application, and I need to build a picture PIL that a Showing in the widget. Image has been correctly built (I can check with Imkshow () are), I can convert a QImage are, I normally save to disk (using QImage.save) But if I try to draw it directly on my QWidget, it only shows a white square.

Here I changed the code (Fig QImage commented not working out so QPixmap result in a white square), and I have a temporary file were a dirty hack to save the image and loaded directly into QPixmap that works, but it does not want to know what I am

an idea anyone?

If it's time to try to save his QImage my BMP file, I can use your content to go, but if I try to save it in PNG is completely white < / p>

If the same problem, found that ImageQt objects are not QImages, but just casted for those Can be done

  #! / Usr / bin / python # - * - coding: UTF -8 - * - # PIL image written PIL by Sebastian stator import cyst in 2010 imports. The PyQt4.QtCore import * def PILimageToQImage (pilimage) from PyQt4.QtGui import * ImageQt import ImageQt: "" "" imageq "QImage PIL image qimage a PIL.ImageQt object converting a PIL image" = ImageQt (pilimage) #convert = QImage (imageq) #cast is the trick that is QImage object for PIL.ImageQt object !!! Return qimage if __name__ == "__main__": #Testcode app = QApplication (sys.argv) PIM = Image.open (. Unicode (QFileDialog () getOpenFileName ())) pim.show () #show PIL image qim = PILimageToQImage (PIM) at = QPixmap (qim) LBL = QLabel () lbl.setPixmap (pm) Lblkshow () #show Qim image sys.exit with labels (app.exec_ ())  
< / Div>

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -