[pygtk] Displaying currency symbols in pyGTK

Robert Boehne rboehne at comcast.net
Wed Jun 18 22:27:54 WST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
John Hunter wrote:
| On Wed, Jun 18, 2008 at 8:33 AM, Robert Boehne <rboehne at comcast.net> 
wrote:
|> -----BEGIN PGP SIGNED MESSAGE-----
|> Hash: SHA1
|>
|> I'm attempting to do what should be simple, and that is display currency
|> symbols in a pango markup label widget.
|> However, when attempting to display the Pound Sterling symbol for the UK
|> currency,
|> I can get it to runder in a python prompt easily:
|>
|> |>> print u'\u001E'
|> <prints pound sterling symbol>
|>
|> but then if I put that in a gtk label it displays as a box with 00  
across
|> the top and 1E across the bottom.
|>
|> Question: What version of pyGTK supports unicode label strings?
|
| It works on the version you have installed.  I have success just
| putting literal unicode into the pango layout.  Where the 'X' in the
| string below is actually and accented e that I am having trouble
| making my browser accept but it is fine in emacs with utf coding
| string (see attached for complete example)
|
|     # -*- coding: utf-8 -*-
|     gc = widget.window.new_gc()
|
|     context = widget.create_pango_context()
|     layout  = widget.create_pango_layout(unicode('DXveloppXs et
| fabriquXs', 'latin-1')
|
|     fontsize = 12  # points
|     scale = dpi/72.0
|
|     desc = pango.FontDescription('Bitstream Vera Sans, normal 12')
|     desc.set_size(int(scale*fontsize)*1024)
|     layout.set_font_description(desc)
|     inkRect, logicalRect = layout.get_pixel_extents()
|     l,b,w,h = inkRect
|     #l,b,w,h = logicalRect
|     x, y = 100, 100
|     widget.window.draw_rectangle( gc, 0, l+x, y+b, w, h)
|     widget.window.draw_layout(gc, x, y, layout=layout)

When I run your example, I see that same box.  This leads me to believe 
it is a setup issue, can anyone point me in the direction of where to look?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
iD8DBQFIWRtqjUrgBL5CXCURAohOAKCFuHnsfMzEnsXY+e0sxG33FHdz+gCfWj4l
A3k1wrtHO9OEVxv3NDHlE5w=
=QvnL
-----END PGP SIGNATURE-----



More information about the pygtk mailing list