On 23/10/2003 8:37 AM, D�vik wrote:

Hi!

I need a TextView that changes its width depending on the maximum number
of characters per line that the user wants it to have. I need that the
user be able to configure it to have between a number of characters per
line and that it changes its width to have exactly the maximum number
they choose.

I mean it for a courier-type font always of the same size.

Is there any way to do it?


Do something like the following:
   context = widget.get_pango_context()
   metrics = context.get_metrics('font name, 12')
   width = pango.PIXELS(metrics.get_approximate_char_width() * n_chars)

For a monospaced font, this should be quite accurate. You can then use widget.set_size_request() to set that as the minimum width for the view.

James.

--
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to