Hung Truong
Hung Truong

Reputation: 369

Tkinter Text widget: Configure font

I have Text widget that I can configure the font families by:

textwidget.config(font=(Consolas,13))

That would configure the whole text Widget. I only want to tell Tkinter I want to make every input after the Text widget has been configured to be like how I changed it.

How can I achieve this. Thanks for any help !!

Upvotes: 0

Views: 1273

Answers (1)

Jonah Fleming
Jonah Fleming

Reputation: 1185

Have a look at the tag commands. You can change the selected text using this code:

number=0
def fontchange():
    textwidget.tag_add(str(number), SEL_FIRST, SEL_LAST)
    textwidget.tag_config(str(number), font=(Consolas,13))
    number += 1

Obviously this is a very basic changer but if you want to change it to the end you could change the SEL_LAST to END. Read this site for more info on tags.

Upvotes: 1

Related Questions