gh-130482: Add ability to specify name for tkinter.OptionMenu and tkinter.ttk.OptionMenu (GH-130502)

This commit is contained in:
Zhikang Yan 2025-05-02 19:38:50 +08:00 committed by GitHub
parent 1e9cc3d502
commit e490c00dac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 19 additions and 2 deletions

View file

@ -354,6 +354,11 @@ def test_bad_kwarg(self):
with self.assertRaisesRegex(TclError, r"^unknown option -image$"):
tkinter.OptionMenu(self.root, None, 'b', image='')
def test_specify_name(self):
widget = tkinter.OptionMenu(self.root, None, ':)', name="option_menu")
self.assertEqual(str(widget), ".option_menu")
self.assertIs(self.root.children["option_menu"], widget)
@add_configure_tests(IntegerSizeTests, StandardOptionsTests)
class EntryTest(AbstractWidgetTest, unittest.TestCase):
_rounds_pixels = (tk_version < (9, 0))