[PyQt] [pyqt]Insert text from sqlite to qtextedit with diffrent fonts and colors

Maziar Parsijani maziar.parsijani at gmail.com
Wed Aug 22 09:15:20 BST 2018


Thanks for your answer
Maurizio Berti

On Tue, Aug 21, 2018 at 2:04 PM, Maurizio Berti <maurizio.berti at gmail.com>
wrote:

> You could use QTextEdit.setHtml by updating each time the html contents,
> or, eventually, use a QTextDocument for the QTextEdit and then edit
> QTextDocument by inserting QTextDocumentFragments.
>
> Il giorno mar 21 ago 2018 alle ore 10:51 Maziar Parsijani <
> maziar.parsijani at gmail.com> ha scritto:
>
>> In this code self.SearchResults = QtWidgets.QTextEdit(self) and it
>> retrieve some text from sqlite3.db Now I need to change font and color for:
>>
>>         self.SearchResults.append('{0} - {1}'.format(a, str(row[0])))
>>         self.SearchResults.append('{0} - {1}'.format(a, str(row[1])))
>>
>> These 2lines retrieve text from database I want them to be different from
>> each other by font and color.
>>
>>   def SearchIn(self):
>>         cur = conn.cursor()
>>         conn.text_factory = str
>>         cur.execute(" SELECT text,text1 FROM Translation WHERE priority = ?", (self.SINDEX,))
>>         self.SearchResults.clear()
>>         a = 1
>>         for row in cur:
>>             self.SearchResults.append('{0} - {1}'.format(a, str(row[0])))
>>             self.SearchResults.append('{0} - {1}'.format(a, str(row[1])))
>>
>>             a = a + 1
>>
>> _______________________________________________
>> PyQt mailing list    PyQt at riverbankcomputing.com
>> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
>
>
> --
> È difficile avere una convinzione precisa quando si parla delle ragioni
> del cuore. - "Sostiene Pereira", Antonio Tabucchi
> http://www.jidesk.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180822/81425fdb/attachment-0001.html>


More information about the PyQt mailing list