'remove highlight color when choosing a combobox value tkinter python
Is there an option to remove the color highlighting when the user chooses the value from the combo box drop down? I'm using the theme "clam" and tried other themes with different ideas but no luck so far. Here is an image of what I'm trying to remove:
Here is my code below:
clean_shift_win = Tk()
clean_shift_win.title('JUSTT Shift Request')
clean_shift_win.geometry('300x200')
dir_path_main_bg = os.path.join(dir_path, r'login window bg.png')
picture = PhotoImage(file=dir_path_main_bg, master=clean_shift_win)
clean_shift_win.option_add('*TCombobox*Listbox.selectBackground', '#30D5C8') # change
highlight color
clean_shift_win.option_add('*TCombobox*Listbox.selectForeground', 'white') # change text
color
clean_shift_canvas = Canvas(clean_shift_win, width=300, height=200,
highlightbackground='#30D5C8', highlightcolor='#30D5C8')
clean_shift_canvas.pack(fill='both', expand=True)
clean_shift_canvas.create_image(0, 0, image=picture, anchor='nw')
clean_shift_canvas.create_text(150,80,fill='turquoise',font='calibri 13 bold',
text='Which Day You Want\n To Delete Your Shift?')
day_chose_to_delete = tk.StringVar(value='Weekday')
day_chose_to_delete_list = ttk.Combobox(clean_shift_canvas,
textvariable=day_chose_to_delete, state='readonly', cursor='hand1', justify='center')
day_chose_to_delete_list['value'] = week
day_chose_to_delete_list.config(font=('calibri', '13'), width=15)
day_chose_to_delete_list.place(x=70, y=110, anchor='nw')
def delete_shift():
MsgBox = tk.messagebox.askquestion('Shift Cancellation','Are You Sure You Want To Delete This Shift', icon = 'warning')
if MsgBox == 'yes':
clear_cells()
clean_shift_win.destroy()
else:
pass
day_to_delete_btn = ttk.Button(clean_shift_canvas, text='Delete This Shift',
cursor='hand2', command=delete_shift)
day_to_delete_btn.place(relx=0.32, rely=0.8, relwidth=0.35, relheight=0.15)
style = ttk.Style(clean_shift_win)
style.theme_use('clam')
style.map('TButton', foreground=[('!disabled', 'white'), ('active', 'white')],
background=[('!disabled', '#550a8a'), ('active', '#550a8a')],
bordercolor=[('!disabled', '#550a8a'), ('active', '#550a8a')],
borderwidth=[('!disabled', 0), ('active', 0)])
style.map('TCombobox', fieldbackground=[('!disabled', 'white'), ('!pressed', 'white')],
background=[('!disabled', '#30D5C8'), ('active', '#30D5C8')],
bordercolor=[('!disabled', '#30D5C8'), ('active', '#30D5C8')],
borderwidth=[('!disabled', 0), ('active', 0)])
clean_shift_win.resizable(False, False)
dir_path_justt_icon = os.path.join(dir_path, r'JUSTT Logo.ico')
clean_shift_win.iconbitmap(dir_path_justt_icon)
clean_shift_win.mainloop()
Solution 1:[1]
So I found out there is an importance of how you insert the config elements when you try to change the theme. Those three lines worked for me.
style = ttk.Style()
combostyle = ttk.Style()
combostyle.theme_create('combostyle', parent='clam', settings = {'TCombobox':
{'configure': {'selectbackground': 'white',
'fieldbackground': 'white',
'background': '#30D5C8',
'bordercolor':'#30D5C8',
'selectforeground': 'black'}}})
style.theme_use('combostyle')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tom |

