为什么我在使用 "ttk." 时无法调整我的 button/label 大小?

Why can't I adjust my button/label size when using "ttk."?

我必须放置一个“ttk”。在我制作的每个标签和按钮后面,否则文本不会显示在标签和按钮上。

myButton = Button(root,text="test",padx=200,pady=20).pack()

在我单击它之前,它只会显示一个没有文本的白色矩形,它会暂时变为蓝色并显示在代码中分配给它的文本。

我的主要问题是当我有“ttk”时我无法更改 padx/pady/columnspan。在我的标签和按钮后面

myButton = ttk.Button(root,text="test",padx=200,pady=20).pack()

此代码导致此错误:

_tkinter.TclError: unknown option "-padx"

如果有人想知道的话,我正在使用 MacO。

那是因为ttk使用padding作为一个关键字。你的例子现在是:

myButton = ttk.Button(root,text="test",padding="200 30 200 30").pack()