[pygtk] Question about gtk.Entry

remi.sassolas at gmail.com remi.sassolas at gmail.com
Mon Apr 24 16:53:49 WST 2006


Hi,

I have a small problem with 'gtk.Entry'. Indeed I would like to change the
color of the text of the Entry, but I don't know how.
I tried to modify the pango.Layout of the Entry (see the small example
bellow), but I didn't work (the text of the Entry was expected to become
red).

# File example.py
import gtk
import pango

def entry_changed_callback(entry):
    end_index = entry.get_text().__len__()
    print end_index

    color = pango.AttrForeground(65535, 0, 0, 0, end_index)
    l = pango.AttrList()
    l.insert(color)

    entry.get_layout().set_attributes(l)


window=gtk.Window()

entry = gtk.Entry()
entry.connect('changed', entry_changed_callback)

window.add(entry)
window.show_all()

gtk.main()
# End of file

Did I make something wrong ? Or is there a way to do it in a different way ?
Thanks in advance for any help provided !
--
Remi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20060424/52b4a3cc/attachment.html


More information about the pygtk mailing list