Twisted Meadow
Twisted Meadow

Reputation: 443

Tkinter: Use different font (color, size, etc.) for the text within the same button?

I have a very specific question.

I have a tkinter button. Each time I click it I get a pop-up window with an Entry box. Enter a text and press enter I can change the text of this button. I can do it as many time as the as I want.

Now the question is: can I make the button text to have different color and font size? Say the original button text is "btn 1". The first time I click it. The text becomes "btn 1\nFirstClick". The second time the text is ""btn 1\nFirstClick\nSecondClick".

I have all the code worked out as I wanted. But now I want "FirstClick" to be in Red and "SecondClick" to be in Green".

Is that possible? I googled and can't find the answer.

Upvotes: 0

Views: 452

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386325

You cannot use multiple fonts or colors in a single button. Your only option would be to create a custom widget that looks and behaves like a button, but which is implemented with a Text or Canvas widget. Those two widgets allow you to use multiple colors and fonts at the same time.

Upvotes: 0

Related Questions