Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,9 @@ tkinter
arguments passed by keyword.
(Contributed by Zhikang Yan in :gh:`126899`.)

* Add default values to the initialization parameters of class
:class:`!tkinter.OptionMenu`.
(Contributed by Zhikang Yan in :gh:`130356`.)

turtle
------
Expand Down
3 changes: 3 additions & 0 deletions Lib/test/test_tkinter/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ def test_bad_kwarg(self):
with self.assertRaisesRegex(TclError, r"^unknown option -image$"):
tkinter.OptionMenu(self.root, None, 'b', image='')

def test_default_parameters(self):
tkinter.OptionMenu(self.root)

@add_configure_tests(IntegerSizeTests, StandardOptionsTests)
class EntryTest(AbstractWidgetTest, unittest.TestCase):
_rounds_pixels = (tk_version < (9, 0))
Expand Down
2 changes: 1 addition & 1 deletion Lib/tkinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4180,7 +4180,7 @@ def __call__(self, *args):
class OptionMenu(Menubutton):
"""OptionMenu which allows the user to select a value from a menu."""

def __init__(self, master, variable, value, *values, **kwargs):
def __init__(self, master=None, variable=None, value="", *values, **kwargs):
"""Construct an optionmenu widget with the parent MASTER, with
the resource textvariable set to VARIABLE, the initially selected
value VALUE, the other menu values VALUES and an additional
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add default values to the initialization parameters of class
:class:`!tkinter.OptionMenu`.
Loading