gpt4 book ai didi

python - 多行 Tkinter 按钮?

转载 作者:太空宇宙 更新时间:2023-11-04 08:09:09 25 4
gpt4 key购买 nike

我有以下按钮:

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

这会生成一个按钮,上面有单词 看看我们可以在一个按钮中放入多少个单词等等,所以这里是 som

我希望文本向下移动到下一行而不是离开按钮的一侧。

另外,我怎样才能使文本不居中?

python 3.3.3.

最佳答案

使用 wraplength 选项是使其环绕的好方法,使用 justify 选项可以做中心以外的事情:

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

wraplength 的值以屏幕单位或像素为单位。您也可以将 '\n' 字符放入字符串中间以手动换行,但如果您这样做,可能还必须手动调整按钮的大小。

关于python - 多行 Tkinter 按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26132192/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com