Question: themed tkinter Radiobutton sunken and raised?
Use the following style options
to hide the indicator
:
indicatorrelief=tk.FLAT,
indicatormargin=-1,
indicatordiameter=-1,
Use style.map(...
to change the background=
color according to the state
.
To hide the indicator
, using theme
clam
or alt
, you need: indicatormargin=-10
import tkinter as tk
import tkinter.ttk as ttk
class App(tk.Tk):
def __init__(self):
super().__init__()
self.title('ttk')
style = ttk.Style(self)
# style.theme_use('alt') # 'aqua', 'step', 'clam', 'alt', 'default', 'classic'
style.configure('IndicatorOff.TRadiobutton',
indicatorrelief=tk.FLAT,
indicatormargin=-1,
indicatordiameter=-1,
relief=tk.RAISED,
focusthickness=0, highlightthickness=0, padding=5)
style.map('IndicatorOff.TRadiobutton',
background=[('selected', 'white'), ('active', '#ececec')])
MODES = [("Monochrome", "1"),
("Grayscale", "L"),
("True color", "RGB"),
("Color separation", "CMYK")]
v = tk.StringVar(self, "L") # initialize
for text, mode in MODES:
ttk.Radiobutton(self, text=text, variable=v, value=mode, width=15,
style='IndicatorOff.TRadiobutton').grid()
if __name__ == "__main__":
App().mainloop()
Tested with Python: 3.5 - 'TclVersion': 8.6 'TkVersion': 8.6