Ttk theme settings

Trying to change the style of Checkbutton, and I'm just curious to know if it is possible to resize the window itself?

This is what I still have. I tried "height" and "width" in the configuration section, but did not seem to pick it up.

    s = ttk.Style()
    s.theme_use('default')
    s.configure("cbutton.TCheckbutton", foreground='#ebebeb', background='#5c5c5c', font=("arial", 14))

    s.theme_settings("default", 
       {"TCheckbutton": {
           "configure": {"padding": 5},
               "map": {
                   "background": [("active", "#5C5C5C"),("!disabled", "#5C5C5C")],
                       "fieldbackground": [("!disabled", "#5C5C5C")],
                   "foreground": [("focus", "lightgray"),("!disabled", "lightgray")], "indicatorcolor": [('selected','#9ac947'),('pressed','#9ac947')]
              }
          }
       })

Is it possible?

Thanks!

+4
source share
1 answer

Element indicator ttk supports background, borderwidth, indicatorcolor, indicatorrelief, indicatordiameterand indicatormargin. All of them are set as theme configuration values, using style.configure()for widget style. You can change the size of the indicator element for the selected Tk topics by changing indicatordiameter. eg:

style = ttk.Style()
style.layout('Custom.Checkbutton', style.layout('TCheckbutton'))
style.map('Custom.Checkbutton', **style.map('TCheckbutton'))
style.configure('Custom.Checkbutton', **style.configure('TCheckbutton'))
style.configure('Custom.Checkbutton', indicatordiameter='24')

checkbutton (TCheckbutton) , .

example of a standard and custom checkbutton

, , , Tk, . , Windows API , . " " Windows, ​​ , , , .

+1

Source: https://habr.com/ru/post/1610483/


All Articles