[Tkinter-discuss] justify text in Text widget

Michael Lange klappnase at web.de
Tue Feb 15 21:45:04 CET 2011


Thus spoketh "Michael O'Donnell" <michael.odonnell at uam.es> 
unto us on Tue, 15 Feb 2011 21:09:03 +0100:

> I had a look at the tcl8.6 page (the most recent version)
> and it only allows -justify: left, right or center.

As far as I see, there is no such option for the widget as a whole, but
only for a particular tag. So in order to right-justify the contents of a
text widget you will need to do:

    textwidget.tag_configure('sometag', justify='right')
    textwidget.tag_add('sometag', 1.0, 'end')

The problem here is that you will have to do this explicitely every time
some new text is inserted into the text widget. Even worse, you will have
to find a way to automatically keep track of the widget's contents.

I don't know if there is a way to configure the text's "default tag" so
you will only have to do this once.

Regards

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

After a time, you may find that "having" is not so pleasing a thing,
after all, as "wanting."  It is not logical, but it is often true.
		-- Spock, "Amok Time", stardate 3372.7


More information about the Tkinter-discuss mailing list