I know there are many ways to change the drop down list/list box font, my question is how could you adjust the entry field at the same time, the part circled in red. How do I make it the same size as the label next to it? In other word, how do i make the drop down arrow bigger?
label = ttk.Label(frame, text='truck id: ', anchor=w, font=bigger_font) c = ttk.Combobox(frame, textvariable=truckID, values=['1','2','3','4']) c['state'] = 'readonly' root.option_add('*TCombobox*Listbox.font', bigger_font)
Advertisement
Answer
Combobox
has a width attribute which lets you control its size. The width
is in terms of the number of characters. So for example, if you know that your combobox entries are single digit numbers, you can set the width attribute as, say 1. Here is an example.
import tkinter as tk import tkinter.ttk as ttk root = tk.Tk() tList = ttk.Combobox(root, values=[1, 2, 3, 4, 5], state="readonly", width=1) tList.current(0) tList.grid(row=0, column=1, padx=10, pady=10) root.mainloop()
Now see, if you change the width to 2.
It is exactly half the size of the combobox entry.
Basically, if you know what kind (length) of entries your combobox will contain, you can control its size.
If you want it to be taller in height, manipulate its font
attribute.
tList = ttk.Combobox(root, values=[1, 2, 3, 4, 5], state="readonly", width=2, font="Verdana 16 bold")