ttk styles
Peter
peter.milliken at gmail.com
Sun Mar 20 20:12:22 EDT 2011
Here is what I came up with - hopefully I have understood the process
correctly and therefore that the comments are correct :-)
I am not sure I have the color of the indicator when it is (de)pressed
correct, but to my eyes the color 'snow' looks like the same color
used with a Tkinter Checkbutton with indicatoron=false.
r = Tk()
s = Style()
# create a layout that excludes the indicator element
s.layout('NoIndicator.TCheckbutton',
[('Checkbutton.border',
{'children': [('Checkbutton.padding',
{'children': [('Checkbutton.label',
{})]})]})])
# Now create(?) a 'setting' for the border appearance of the
checkbutton
s.theme_settings('default', {
'NoIndicator.TCheckbutton': {'configure': {'relief': ''}}})
# set the attributes of the 'setting' to provide the required
behaviour
s.map('NoIndicator.TCheckbutton',
relief=[('disabled', 'flat'),
('selected', 'sunken'),
('pressed', 'sunken'),
('active', 'raised'),
('!active', 'raised')],
background=[('selected', 'snow')])
button = Checkbutton(r,
text='Test',
style='NoIndicator.TCheckbutton')
button.pack()
r.mainloop()
More information about the Python-list
mailing list