Jose Ignacio Centeno
Jose Ignacio Centeno

Reputation: 461

How can I get a text width?

I want to modify a Gtk.Entry to fit its text width, how can I get the text width?. I've tried setting an average width for each character, but It don't work properly

Upvotes: 3

Views: 660

Answers (1)

apmasell
apmasell

Reputation: 7153

GTK+ widgets have their rendering layout done by Pango, so first, create a Pango Layout for your widget by calling create_pango_layout with the text you want on your Gtk.Entry and then use get_size to get the dimensions.

Upvotes: 3

Related Questions