2014-10-01 116 views
1

我有以下按鈕:多行Tkinter按鈕?

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

這使得其具有話see how many words we can fit in a button and stuff so heres som的按鈕。

我希望文本向下移動到下一行而不是按下按鈕的一側。

另外,我該如何讓文本不居中?

python 3.3.3。

+0

您可以使用相同的命令創建兩個按鈕,一個在另一個上方,但寫入不同,這將顯示爲一個按鈕。 – W1ll1amvl 2014-10-01 01:45:36

回答

6

使用wraplength選項是使其包裹的好方法,而justify選擇做其他的東西比中心:

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

wraplength值是屏幕單位或像素。您也可以將一個'\n'字符放入字符串的中間以手動打破該行,但如果您這樣做,也可能必須手動調整該按鈕的大小。