How to change the font of the popdown / dropdown window (the listbox) in a combobox in Ruby/tk?

Viewed 35

I have read solutions of it in Python, Tcl... but not for Ruby/tk.

I know it requires the use of some command or piece of code I do not know... I am new to this.

Please note that I am not asking for a gem or anything, which I know is off-topic. Just a command or a line code to solve my problem.

Here is what I have done until now: the first and last three lines, which are my attempts to change the font of the Combobox popdown window, make different errors (in the code of my program I wrote # in order to evade them and I mark them here so you can see what should be corrected).

    # font = TkFont.new('Calibri 14')
    # option add *TCombobox*Listbox.font # font
    # option add *ComboboxPopdown.f.l.font 
    comboboxtema = TkCombobox.new(framemedio)
    comboboxtema.width = 47
    comboboxtema.values = ["1", "2", "3", "4", "5", "6"]  
    comboboxtema.set("Select number")
    comboboxtema.state('readonly')
    comboboxtema.font TkFont.new('Calibri 14')
    comboboxtema.pack
    # comboboxtema::PopdownWindow.font TkFont.new('Calibri 14')
    # set popdown [Tk::Tile::Tcombobox::PopdownWindow .mycombobox]
    # $popdown.f.l configure -font('Calibri 14')

Again, thanks so much!

1 Answers

I found myself the solution and I share it so everyone with the same problem can see how I solved it.

The trick is to modify the default font. The font that displays the dropdown list from the Combobox is TkTextFont.

TkFont.configure('TkTextFont', 'family' => 'Lucida Sans Unicode', 'size' => '10')

Thanks to the post in this link, who made me come up with the solution:

https://www.thecodingforums.com/threads/how-can-i-change-the-default-font-size-in-tk.838119/

Related