Python tkinter ttk combobox

Python tkinter ttk combobox

tkinter ttk theme combobox

It is a new widget. This widget is a combination of an Entry and a drop-down menu. You will see the usual text entry area, with a downward-pointing arrow. When the user clicks on the arrow, a dropdown menu appears. If the user clicks on one, that choice replaces the current contents of the entry.

b = ttk.Combobox()


The cursor that will appear when the mouse is over
the widget


By default, if you select text within an Entry widget, it is
automatically exported to the clipboard.


Option to specify a maximum number of rows that will
appear in the drop-down menu; the default is 20.


Specifies howt he text will be positioned within the entry area when
it does not completely fill the area. tk LEFT, tk.CENTER or tk.RIGHT


A variable that controls the text that appears in
the entry area


You may use this option to request dynamic validation of the widget's
text content.


The choices that will appear in the drop-down menu,
as a sequence of strings.


This option specifies the width of the entry area as a number of


If the widget has an associated horizontal
scrollbar, set this option to the .set method of that scrollbar.

Checkbutton methods :
Methods on a ttk.Combobox include all those described in Section 46, “Methods common to all ttk
widgets” (p. 145), plus all the methods on the Tkinter widget described in Section 10, “The Entry widget” (p. 41), plus:

1) current([index])
To select one of the elements of the values option, pass the index of that element as the argument
to this method.

2) set(value)
Set the current text in the widget to value.

3) get()
Returns the entry's current text as a string

Example :
import tkinter as tk
from tkinter import ttk

window = tk.Tk()

ttk.Label(window, text =
"Combobox Widget", font = ("Times New Roman", 15)).grid(row = 0, column = 1)

ttk.Label(window, text =
"Select the Month :", font = ("Times New Roman", 10)).grid(column = 0,
row =
5, padx = 10, pady = 25)

n = tk.StringVar()
monthchoosen = ttk.Combobox(window, width =
27, textvariable = n)

'values'] = (
' January',
' February',
' March',
' April',
' May',
' June',
' July',
' August',
' September',
' October',
' November',
' December')

monthchoosen.grid(column =
1, row = 5)