tkinter ttk style

Phil <[email protected]> Thu, 9 May 2024 13:23:38 +1000
Newsgroups gmane.comp.python.tutor
Message-ID <[email protected]>
I've spent a lot of time reading documentation and tying to adapt 
examples to set two ttk buttons to different background colours without 
success.

Using the following code both buttons have the same background colour.

         self.style = ttk.Style()
         self.style.configure("TButton", background="orange")
         self.style.configure("TButton.another_button", background="pink")

         exit_button = ttk.Button(frame, text="Exit", command=self.destroy)
         exit_button.grid(column=3, row=3, padx=5, pady=5)

         anothert_button = ttk.Button(frame, etc)

I've even resorted to asking my AI friend for help and eventually I got 
working code that included the following. Although it works almost 
perfectly (the pink button is smaller than the exit button for some 
reason) the code seems to be unnecessarily convoluted.

         self.style.layout(
             "TButton.another_button",
             [
                 (
                     "Button.focus",
                     {
                         "children": [
                             (
                                 "Button.padding",
                                 {"children": [("Button.label", 
{"sticky": "nswe"})]},
                             )
                         ]
                     },
                 )
             ],
         )

Again, any tips will be greatly appreciated.

-- 
Regards,
Phil
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor