[gtk+-2.2.1, pygtk-1.99.15, python 2.3a1]
I want to have an Entry change it's width to exactly track the
width of it's string contents. What I have *almost* works: after
I click on the widget and change something, it's fine. But initially
only part of the string is shown. Here's my code:
import gtk, pango
def ch_cb(w):
l = w.get_layout()
w.set_size_request((2 * w.get_layout_offsets()[0]) +
l.get_pixel_size()[0], -1)
top = gtk.Window(gtk.WINDOW_TOPLEVEL)
top.show()
e = gtk.Entry()
e.modify_font(pango.FontDescription('monospace'))
e.connect('changed', ch_cb)
e.show()
h=gtk.HBox()
top.add(h)
h.show()
e.set_text('the rain in spain stays')
h.pack_start(e,gtk.TRUE, gtk.FALSE, 0)
gtk.mainloop()
If the set_text line is put *after* the pack_start, then it
works properly. It seems as if the font width info is incorrect
until there is a complete chain of parent widgets up to the top.
I tried e.connect("realize",ch_cb), likewise with "map" and "show"
but to no avail. Is there some event I can connect to that would
happen late enough? Changing the font via gtkrc file
fails the same.
-- George
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/