Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e48741a

Browse files
Merge heads
2 parents b83a86a + 4cf4f3a commit e48741a

3 files changed

Lines changed: 48 additions & 1 deletion

File tree

Lib/tkinter/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def tk_setPalette(self, *args, **kw):
380380
background, highlightColor, selectForeground,
381381
disabledForeground, insertBackground, troughColor."""
382382
self.tk.call(('tk_setPalette',)
383-
+ _flatten(args) + _flatten(kw.items()))
383+
+ _flatten(args) + _flatten(list(kw.items())))
384384
def tk_menuBar(self, *args):
385385
"""Do not use. Needed in Tk 3.6 and earlier."""
386386
pass # obsolete since Tk 4.0
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import unittest
2+
import tkinter
3+
from tkinter import ttk
4+
from test import support
5+
6+
support.requires('gui')
7+
8+
class MiscTest(unittest.TestCase):
9+
10+
def setUp(self):
11+
self.root = ttk.setup_master()
12+
13+
def test_tk_setPalette(self):
14+
root = self.root
15+
root.tk_setPalette('black')
16+
self.assertEqual(root['background'], 'black')
17+
root.tk_setPalette('white')
18+
self.assertEqual(root['background'], 'white')
19+
self.assertRaisesRegex(tkinter.TclError,
20+
'^unknown color name "spam"$',
21+
root.tk_setPalette, 'spam')
22+
23+
root.tk_setPalette(background='black')
24+
self.assertEqual(root['background'], 'black')
25+
root.tk_setPalette(background='blue', highlightColor='yellow')
26+
self.assertEqual(root['background'], 'blue')
27+
self.assertEqual(root['highlightcolor'], 'yellow')
28+
root.tk_setPalette(background='yellow', highlightColor='blue')
29+
self.assertEqual(root['background'], 'yellow')
30+
self.assertEqual(root['highlightcolor'], 'blue')
31+
self.assertRaisesRegex(tkinter.TclError,
32+
'^unknown color name "spam"$',
33+
root.tk_setPalette, background='spam')
34+
self.assertRaisesRegex(tkinter.TclError,
35+
'^must specify a background color$',
36+
root.tk_setPalette, spam='white')
37+
self.assertRaisesRegex(tkinter.TclError,
38+
'^must specify a background color$',
39+
root.tk_setPalette, highlightColor='blue')
40+
41+
42+
tests_gui = (MiscTest, )
43+
44+
if __name__ == "__main__":
45+
support.run_unittest(*tests_gui)

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ Core and Builtins
189189
Library
190190
-------
191191

192+
- Issue #16541: tk_setPalette() now works with keyword arguments.
193+
192194
- Issue #16820: In configparser, `parser.popitem()` no longer raises ValueError.
193195
This makes `parser.clean()` work correctly.
194196

0 commit comments

Comments
 (0)