Hi,

I have a program which, I believe, should do the same thing in both
Python and C - set pango attributes on a label. The C version works
as expected. In PyGTK version attributes get applied only on the first
character. Any ideas why does this happen? I attach both test cases.

Versions used:
PyGTK 2.14.1
PyCairo 1.8.6
PyGObject 2.18.0
Python 2.6.2
GTK+ 2.16.2
Cairo 1.8.8
Pango 1.24.3

Thanks in advance.

-- 
The fact is, most software is crap, and most software developers
are lazy and stupid. Same as most customers are stupid too.
                         -- Hua Zhong, Linux Kernel Mailing List
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import gtk
import pango

if __name__ == '__main__':

        label = gtk.Label()
        label.set_text('abc ABC ' * 3)

        attrs = pango.AttrList()

        attrs.insert(pango.AttrStyle(pango.STYLE_ITALIC))
        attrs.insert(pango.AttrSize(20000))
        label.set_attributes(attrs)

        win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        win.add(label)
        win.connect('destroy', gtk.main_quit)

        win.show_all()
        gtk.main()
/*
 * Compile:
 * cc `pkg-config --cflags --libs gtk+-2.0` label.c -o label
 *
 */

#include <gtk/gtk.h>

int main(int argc, char *argv[]) {
        gtk_init(&argc, &argv);

        GtkWidget *label = gtk_label_new("abc ABC abc ABC abc ABC");

        PangoAttrList *attrs = pango_attr_list_new();
        PangoAttribute *attr1 = pango_attr_style_new(PANGO_STYLE_ITALIC);
        PangoAttribute *attr2 = pango_attr_size_new(20000);

        pango_attr_list_insert(attrs, attr1);
        pango_attr_list_insert(attrs, attr2);

        gtk_label_set_attributes(GTK_LABEL(label), attrs);
        pango_attr_list_unref(attrs);

        GtkWidget *window  = gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_container_add(GTK_CONTAINER(window), label);
        g_signal_connect(G_OBJECT(window), "destroy", 
G_CALLBACK(gtk_main_quit), NULL);

        gtk_widget_show_all(window);
        gtk_main();

        return 0;
}
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to