[pygtk] Displaying currency symbols in pyGTK
John Hunter
jdh2358 at gmail.com
Wed Jun 18 22:12:32 WST 2008
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 =3D widget.window.new_gc()
context =3D widget.create_pango_context()
layout =3D widget.create_pango_layout(unicode('DXveloppXs et
fabriquXs', 'latin-1')
fontsize =3D 12 # points
scale =3D dpi/72.0
desc =3D pango.FontDescription('Bitstream Vera Sans, normal 12')
desc.set_size(int(scale*fontsize)*1024)
layout.set_font_description(desc)
inkRect, logicalRect =3D layout.get_pixel_extents()
l,b,w,h =3D inkRect
#l,b,w,h =3D logicalRect
x, y =3D 100, 100
widget.window.draw_rectangle( gc, 0, l+x, y+b, w, h)
widget.window.draw_layout(gc, x, y, layout=3Dlayout)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pango_demo2.py
Type: text/x-python
Size: 1429 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20080618/fd18b663/p=
ango_demo2.py
More information about the pygtk
mailing list