Answer the question
In order to leave comments, you need to log in
How to insert an image in a QTextEdit (QTextDocument) if the image is stored in bytes? PyQt4.?
Python 3.3 + PyQt4
Task: insert pictures (formulas) into text.
I know that by specifying the path to the image, you can insert it into the QTextDocument. But my pictures are stored in bytes (class bytes). I don't even have an idea how to show such images in the text. For example, I will give the following code.
import sys
from PyQt4 import QtGui
app=QtGui.QApplication(sys.argv)
editor=QtGui.QTextEdit()
editor.setGeometry(300, 200, 350, 300)
editor.show()
fin=open('formula.jpg', 'rb') # Это я чисто для примера
byt=fin.read() #Из базы данных изображении беру в таком виде
fin.close()
#Тут надо показать byt как картинку в editor (QTextEdit, QTextDocument,...)
#Можно любые средства использовать
sys.exit(app.exec_())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question