Home > Back-end >  Why can't I adjust my button/label size when using "ttk."?
Why can't I adjust my button/label size when using "ttk."?

Time:10-08

I have to place a "ttk." behind every labels and buttons that I make because otherwise the text wouldn't display on the labels and buttons.

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

This would just display a white rectangular with no text until I clicked it which temporary changes to blue and displays the text that was assigned to it in the code.

My main problem is that I'm not able to change the padx/pady/columnspan when I have the "ttk." behind my labels and buttons

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

This code results in this error:

_tkinter.TclError: unknown option "-padx"

I am using MacOs if anyone's wondering.

CodePudding user response:

That's because ttk uses padding as one keyword. Your example would be now:

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