Text component with different font style text : TextArea « GUI Tk « Python






Text component with different font style text

Text component with different font style text
from Tkinter import *

root = Tk()
root.title('Text')
text = Text(root, height=26, width=50)
scroll = Scrollbar(root, command=text.yview)


text.configure(yscrollcommand=scroll.set)

text.tag_configure('bold_italics', font=('Verdana', 12, 'bold', 'italic'))

text.tag_configure('big', font=('Verdana', 24, 'bold'))

text.tag_configure('color', foreground='blue', font=('Tempus Sans ITC', 14))

text.tag_configure('groove', relief=GROOVE, borderwidth=2)

text.tag_bind('bite', '<1>',
              lambda e, t=text: t.insert(END, "I'll bite your legs off!"))

text.insert(END, 'A?\n')

text.insert(END, 'B?\n', 'bold_italics')

text.insert(END, 'C "Frank"?\n', 'big')

text.insert(END, "D?\n", 'color')

text.insert(END, 'E?\n', 'groove')

button = Button(text, text='Button')

text.window_create(END, window=button)

text.insert(END, 'I dare you to click on this\n', 'bite')

text.pack(side=LEFT)

scroll.pack(side=RIGHT, fill=Y)

root.mainloop()
           
       








Related examples in the same category

1.Simple Text (TextArea): font, color, grooveSimple Text (TextArea): font, color, groove
2.Text with font settingsText with font settings
3.Text with a button insideText with a button inside