[PyQt] Using Unicode
Gabriel Hahmann
gabriel.hahmann at gmail.com
Wed Jun 17 19:06:06 BST 2009
I've tried this way but didnt work. Maybe I forget to change something.
In fact I've tried the "u" thing that Raoul said:
QtGui.QPushButton(self.tr(u'&Next >'))
And worked perfectly as I expected.
Thanks for everyone that helped me.
[]'s
Gabriel.
On Wed, Jun 17, 2009 at 2:08 PM, Detlev
Offenbach<detlev at die-offenbachs.de> wrote:
> On Mittwoch, 17. Juni 2009, Gabriel Hahmann wrote:
>> On Wed, Jun 17, 2009 at 12:57 PM, projetmbc<projetmbc at club-internet.fr>
> wrote:
>> > projetmbc a écrit :
>> >> dial_project_2 is just my GUI class. For example, the example that I
>> >> give comes frome something like that
>> >> class dial_Projet2(QtGui.QDialog, Ui_dial_Projet2):
>> >> ....
>> >>
>> >> Ui_dial_Projet2 is a Python file created from a Dialog built with Qt
>> >> Designer.
>> >>
>> >> I hope that I'm clear.
>> >>
>> >> Christophe.
>> >>
>> >> PS : Maybe it is possible to subclass the metho tr(). I never try for
>> >> the moment but it could be an easy way to implement unicode without
>> >> doing boring changes.
>> >
>> > I've just tried the subclass technique and it "seems" to work. So the
>> > simple thing you have to do is to add the following method in the code
>> > your pyQtr class :
>> > ----------------------------
>> > def tr(self, text):
>> > return QtGui.QApplication.translate("putHereTheNameOfYourClass",
>> > text, None, QtGui.QApplication.UnicodeUTF8)
>> > ----------------------------
>> >
>> > Christophe.
>>
>> I'll try this today and then I would let you know the results.
>>
>> []'s
>> Gabriel.
>>
>> _______________________________________________
>> PyQt mailing list PyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> An even easier solution is to use trUtf8() instead of tr(). Make sure your
> Python files contain a coding line for utf8.
>
> Regards,
> Detlev
> --
> Detlev Offenbach
> detlev at die-offenbachs.de
>
More information about the PyQt
mailing list