import tkinter as tk import tkinter.ttk as ttk import tkinter.font as tkfont def on_combo_configure(event,fruit): #font = tkfont.nametofont(str(event.widget.cget('font'))) fontstring = event.widget.cget('font') font = tkfont.nametofont('TkDefaultFont') font.configure(family=fontstring.string.split(" ")[0]) font.configure(size=fontstring.string.split(" ")[1]) maxelemfromList = max(enumerate(fruit), key=lambda x: len(x[1]))[1] width = font.measure(maxelemfromList + "0") - event.width style = ttk.Style() style.configure('TCombobox', postoffset=(0,0,width,0)) root = tk.Tk() root.title("testing the combobox") root.geometry('500x500+50+50') ownfont = tkfont.Font(family="Verdana",size=13) root.option_add("*TCombobox*Listbox*Font", ownfont) fruit = ['apples are the best', 'bananas are better', 'sveti\'s ideas are the best','nice try','z','#'] #c = AutoCombobox(root, values=fruit, width=10, textvariable="Test Variable") c = ttk.Combobox(root, values=fruit, width=5, textvariable="Test Variable",font="Verdana 13") #c = ttk.Combobox(root, values=fruit, width=10, textvariable="Test Variable") #c.bind('<>', lambda e: on_combo_configure(e, fruit)) c.bind('', lambda e: on_combo_configure(e, fruit)) c.pack() root.mainloop()