[PySide] trouble with special characters in widget.setToolTip()
Frank Rueter | OHUfx
frank at ohufx.com
Wed Mar 2 07:20:09 CET 2016
Hi guys,
I've been reading up on unicode and character encoding a bit today and
just when I thought I had a vague idea how it all works I ran into this
problem:
I am retrieving unicode from a website, which I need to format a little,
then display as a widget's tooltip.
When I print out my formatted string I get the special characters I
expect, but when I use the same string as a tooltip, it displays a "å"
character instead.
Here is a screen shot of what I'm seeing:
And below is a simple test that shows my problem.
Can somebody please explain to me what is going on here and how I should
be handle this properly?
Cheers,
frank
import sys
from PySide import QtGui
quotationMark = u'\u201c'
myText = 'special charactes cause headaches:
{}'.format(quotationMark.encode('utf-8'))
print myText # this prints the crrect special character (quotation mark)
app = QtGui.QApplication([])
w = QtGui.QWidget()
w.setToolTip(myText) # this just ends up displaying a "å" character
w.show()
w.raise_()
sys.exit(app.exec_())
--
ohufxLogo 50x50 <http://www.ohufx.com> *vfx compositing
<http://ohufx.com/index.php/vfx-compositing> | *workflow customisation
and consulting <http://ohufx.com/index.php/vfx-customising>* *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20160302/5429ef52/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2016-03-02 at 7.19.05 pm.png
Type: image/png
Size: 21640 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20160302/5429ef52/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ohufxLogo_50x50.png
Type: image/png
Size: 2666 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20160302/5429ef52/attachment-0001.png>
More information about the PySide
mailing list