Search code examples
pythontkinterttk

Remove blue highlighting when selecting combobox python


I have made a combobox and I want to remove the blue highlight when I have selected an item.

I'm a beginner in Python and I'm looking to create a Python interface using tkinter. I have explored all the posts and sites and I have not been able to solve my problem. I could see several sites around SelectionStart, SelectionLength, selection_clear, selectionbrush but without success....

# -*- coding: UTF-8 -*-
from tkinter import *
import tkinter.ttk as ttk

#rootframe
root = Tk()
root.geometry("900x570") 
root.configure(background='#ffffff')

###frame
Frame1 = Frame(root,width=256, height=370, background="#cbf1f5")
Frame1.place(x=20, y=20)

#title frame
label_title_ech = Label(Frame1, text="""Échelle d'analyse""",font='Helvetica 12 bold', width='22', background="#71c9ce") 
label_title_ech.place(x=15, y=20)

#choice of analysis scale
combobox1 = ttk.Combobox(Frame1, values=["Mailles de 5km", "Mailles de 2.5km", "Mailles de 1km", "Mailles de 500m"])
combobox1.place(x=55,y=70)
combobox1.current(0)
root.option_add('*TCombobox*Listbox.selectBackground', '#71c9ce') 
root.option_add('*TCombobox*Listbox.selectForeground', 'white') 
root.mainloop()

So I would like to remove the blue highlight when I choose an item.

Thank you for your help. Vincent


Solution

  • Not sure why you wanted to do this, but you can bind an event to <<ComboboxSelected>> and move focus to another widget to avoid the blue highlight:

    combobox1.bind("<<ComboboxSelected>>",lambda e: Frame1.focus())