Tkinter - Text - bullets

eb303 eric.brunel at pragmadev.com
Fri Sep 18 11:50:36 EDT 2009


On Sep 18, 11:57 am, Thomas Lehmann <Iris-und-Thomas-Lehm... at T-
Online.de> wrote:
> My intention is to write a small custom widget displaying text where
> the text can have a simple wiki syntax. The main interest is to
> support heading, bold, italic, underline, itemization and enumeration.
>
> How can I implement itemization using the Tkinter.Text widget?
> (bullets)

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')

root.mainloop()
----

HTH



More information about the Python-list mailing list