O'Reilly logo

Tkinter GUI Programming by Example by David Love

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The OptionMenu and Combobox widgets

The OptionMenu and Combobox widgets are used to give the user the choice of one option from a group, much like a Radiobutton. They both display in a similar manner to a drop-down menu, or select menu, from HTML.

Whereas the OptionMenu widget only allows the user to choose an option that is in the menu, the Combobox widget essentially combines an Entry widget with the OptionMenu widget, allowing the user to type their own choice into the box as well.

We can have a look at these two widgets with a small piece of code:

import tkinter as tkimport tkinter.ttk as ttkwin = tk.Tk()options = ("low", "medium", "high")om_chosen = tk.StringVar()

To prepare for these two widgets, we need a Tkinter variable to store ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required