I would like to create a custom theme for my app. I can't get the button widget to expand in my code below. I can configure the button using the minimum width parameter but it should expand to fit the text as specified under layout.
Any ideas what is wrong with the code below?

    import tkinter
    from tkinter import ttk
    root = tkinter.Tk()
    colors = {
              "frame": "#efefef",
              "disabledfg": "#aaaaaa",
              "selectbg": "#657a9e",
              "selectfg": "#ffffff"
             }

    style = ttk.Style()
    style.theme_create("test", "default", settings={
        ".": {
            "configure":
                {"background": colors['frame'],
                 "troughcolor": colors['frame'],
                 "selectbackground": colors['selectbg'],
                 "selectforeground": colors['selectfg'],
                 "fieldbackground": colors['frame'],
                 "font": "TkDefaultFont",
                 "borderwidth": 1},
            "map": {"foreground": [("disabled", colors['disabledfg'])]}
        },
        "TButton": {
                    "configure": {"width": 10, "anchor": "left"},
                    "layout": [
                        ("Button.button", {"children":
                            [("Button.focus", {"children":
                                [("Button.padding", {"children":
                                    [("Button.label", {"side": "left", "expand": 1})]
                                })]
                            })]
                        })
                    ]
                }})

    style.theme_use("test")
    button_send = ttk.Button(root, text="TEST BUTTON ONLY!").grid(row=0, column=0, padx=50, pady=50)

    root.mainloop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.