2014-10-01 119 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'字符放入字符串的中间以手动打破该行,但如果您这样做,也可能必须手动调整该按钮的大小。