如何使用Python Tkinter修复按钮文本的大小?

2024-06-16 09:43:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下示例代码:

    # Button grid modifications
    self.connectButton.grid(row=5, columnspan=2,
        sticky=N + S + E + W)
    self.SelectButton.grid(row=6, rowspan=2, column=0,
        sticky=N + S + E + W)
    self.configButton.grid(row=6, rowspan=2, column=1,
        sticky=N + S + E + W)
    self.ImageButton.grid(row=7, columnspan=2,
        sticky=N + S + E + W)
    self.ImageButton2.grid(row=8, columnspan=2,
        sticky=N + S + E + W)

这将在两个1列按钮上显示一个2列按钮,再在几个2列按钮上显示一个1列按钮。根据我所使用的文本,它在垂直和水平方向上都会发生剧烈和不相称的变化。我试过使用weight=1,但似乎也不起作用。我知道必须有一个简单的解决办法。我怎样才能让它在不考虑文本/平台的情况下保持一致?这应该是便携式的。你知道吗

谢谢你的帮助。你知道吗


Tags: 代码文本self示例columnbutton按钮grid