PDA

View Full Version : codepage in PyQT textedit



lipati
9th April 2019, 15:35
position_list, result_list = get_one_image_result(self.file_name[0][self.curFileIndex])
#print(result_list)
strResult = self.dealRecogResultList(result_list)
f = open(self.file_name[0][self.curFileIndex] + '.txt', 'w', encoding="utf-8")
f.write(strResult)
#outText = strResult.decode('utf-8')
self.plainTextEdit_result.insertPlainText(strResul t)

It's a application for windows desktop, i use a textedit to display some Chinese minority language characters, like:??????????????????????????.
But it only displays some small black pieces.Even I use ctrl+C and ctrl+V to copy some characters from notepad to textedit, it displays the same small black pieces.
PyQT cannot show this characters at all?

13079
13080

anda_skoa
9th April 2019, 16:32
Have you checked if the currently used font contains these characters?

Cheers,
_

lipati
10th April 2019, 03:57
Have you checked if the currently used font contains these characters?

Cheers,
_

Thank for your reply. The problem is solved.
It's my fault, i tried wrong font: self.setFont(QFont("??", 12))
This font can display the characters correctly in notepad, but I realized this font does not support this character(the windows system is processed adaptively).
So I download proprietary font and set it: self.plainTextEdit_result.setFont(QFont("hope", 12))
and the problem is solved.