Thedudxo
Thedudxo

Reputation: 591

multi line Tkinter button?

i have the following button:

option1=tkinter.Button(opt1,text='this is a test to see how many words we can fit in a button and stuff so heres some more words',width=49,height=3,bg='grey',)

this makes a button which has the words see how many words we can fit in a button and stuff so heres som.

i want the text to move down to the next line instead of going off the side of the button.

also, how can i make it so the text is not centred?

python 3.3.3.

Upvotes: 6

Views: 13400

Answers (1)

Crowman
Crowman

Reputation: 25908

Using the wraplength option is a good way to make it wrap, and the justify option to do something other than center:

option1 = tkinter.Button(opt1, wraplength=80, justify=LEFT, text='This is the text')

The value of wraplength is in screen units, or pixels. You can also just drop a '\n' character into the middle of your string to break the line manually, but may also have to size the button manually if you do this.

Upvotes: 12

Related Questions