我有以下按钮:
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
.
我希望文本向下移动到下一行,而不是离开按钮的一侧。
另外,我怎样才能使文本不居中?
蟒蛇3.3.3。
使用wraplength
选项是使其换行的好方法,并且justify
可以选择做中心以外的事情:
option1 = tkinter.Button(opt1, wraplength=80, justify=LEFT, text='This is the text')
的价值wraplength
以屏幕单位或像素为单位。您也可以只删除一个'\n'
字符插入字符串中间以手动换行,但如果执行此操作,可能还需要手动调整按钮的大小。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)