0

I used ttk.Combobox to make a dropdown menu so that the user can select their sex ("sesso" in italian), and this is the code that i used:

sessi = ["M", "F"]

sesso_menu = ttk.Combobox(value=sessi, font=("Calibri", 16), state="readonly")
sesso_menu.place(x=4, y=4, height=32, width=52)
sesso_menu.current(0)

It looks like this but now want to change the font of the two variables inside the window that pops up to make them bigger, how do i do this?

1 Answer 1

6

You can use .option_add() to set the font but it applies to all Combobox:

import tkinter as tk

root = tk.Tk()
root.option_add("*TCombobox*Listbox.font", "Calibri 16")

...

Or you can get the Popdown Window of sesso_menu via TCL command and configure the font of the listbox inside the Popdown Window:

popdown = root.tk.call("ttk::combobox::PopdownWindow", sesso_menu)
root.tk.call(f"{popdown}.f.l", "configure", "-font", "Calibri 16")
2
  • root.option_add("TComboboxFont", "Calibri 16") will also work.
    – Doc
    Apr 6 at 13:43
  • Also self.option_add("*TCombobox*Listbox.font", custom_font) works, where custom_font is declared = font(family, size) and self is a subclass of tk.Frame. Jun 11 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.