Tkinter - Text - bullets

Thomas Lehmann Iris-und-Thomas-Lehmann at T-Online.de
Sat Sep 19 11:53:29 EDT 2009


> Something like this maybe?
> ----
> from Tkinter import *
>
> root = Tk()
> txt = Text(root, wrap='word')
> txt.pack()
>
> txt.tag_configure('text_body', font=('Times', 18), lmargin1=0,
> lmargin2=0)
> txt.tag_configure('bulleted_list', font=('Times', 18), lmargin1='10m',
> lmargin2='15m', tabs=['15m'])
>
> txt.insert(END, u"This is a normal paragraph. Let's make it a bit long
> to see that it wraps as expected.\n", 'text_body')
> txt.insert(END, u"\u00B7\tThis is the first item in the list.\n",
> 'bulleted_list')
> txt.insert(END, u"\u00B7\tThis is the second item in the list. Let's
> make this one quite long too to see how it wraps.\n", 'bulleted_list')

Thank you very much!
However, the result is not that pretty as I have expected. The bullets
are really small. When separating bullet and text then I can increase
the font size for the bullet but then it does not fit to the text -
vertical alignment is wrong. Also it's pretty unhandy to adjust the
margins so that the text continues on next line starting at the same
position as the first character from previous line.

But it is a starting. I will check whether it is possible to place an
image for a bullet. The size and position handling will be still there
then -  I think so.

Also note: The tab value from your example has not been accepted (s.th
like. "invalid screen distance")



More information about the Python-list mailing list