PCPP 32 10x PCPP Certified Professional Python Programmer 1 · Free Practice Question Easy
Question 3
In Python's Tkinter module, which widget is used to create a drop-down menu with a list of options from which the user can select?
-
A
OptionMenu -
B
Radiobutton -
C
Entry -
D
Checkbutton
Reveal correct answer
Correct answer: A
A.
The OptionMenu widget is correct. It is used in Tkinter to create a drop-down menu with a list of options that the user can select from. The first parameter is the parent widget, the second is a variable (usually a StringVar), and the remaining parameters are the options for the user to choose from.
B.
The Radiobutton widget is incorrect because it is used to display a number of options as radio buttons. While a user can only select one option (like a drop-down menu), the options are not hidden away like they are in a drop-down menu.
C.
The Entry widget is incorrect as it is used to create single-line text fields for user input. It doesn't provide a drop-down menu with a list of options.
D.
The Checkbutton widget is incorrect because it is used to display a number of options as checkboxes. A user can select more than one option, which does not match the behaviour of a drop-down menu.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
