From pykde Thu Mar 07 16:26:39 2024 From: Phil Thompson Date: Thu, 07 Mar 2024 16:26:39 +0000 To: pykde Subject: Re: Converted ui file throws UnicodeEncodeError: 'utf-8' codec can't encode characters in position 1 Message-Id: X-MARC-Message: https://marc.info/?l=pykde&m=170982868923019 On 04/03/2024 02:30, lizhao0512@126.com wrote: > After converting the ConfigWindow.ui to Ui_ConfigWindow.py, and then > run ConfigWindow-test.py with it, I got the following error. Test > files are attached. > > Traceback (most recent call last): > File > "F:\BaiduNetdiskDownload\SoftwareProject\LYYDownloader-dev\ConfigWindow.py", > line 64, in > ui = ConfigWindow() > File > "F:\BaiduNetdiskDownload\SoftwareProject\LYYDownloader-dev\ConfigWindow.py", > line 27, in __init__ > self.setupUi(self) > File > "F:\BaiduNetdiskDownload\SoftwareProject\LYYDownloader-dev\Ui_ConfigWindow.py", > line 179, in setupUi > self.retranslateUi(Dialog) > File > "F:\BaiduNetdiskDownload\SoftwareProject\LYYDownloader-dev\Ui_ConfigWindow.py", > line 211, in retranslateUi > self.label.setText(QCoreApplication.translate("Dialog", " HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" > \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" > UnicodeEncodeError: 'utf-8' codec can't encode characters in position > 1047-1048: surrogates not allowed It looks like you have used Qt's uic to generate the .py file. As far as I know uic doesn't support PyQt. Did you edit the .py file to use PyQt? Whatever - if you use pyuic6 then it works as expected - and the generated code is readable. Phil