Skip to content

Commit 0410c43

Browse files
committed
bpo-42328: ttk fix handling of default states in style map
1 parent cda99b4 commit 0410c43

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Lib/tkinter/test/test_ttk/test_functions.py

+3
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ def test_it(sspec, value, res_value, states):
348348

349349
test_it(('a', 'b', 'c'), MockTclObj('val'), 'val', ('a', 'b', 'c'))
350350

351+
spec = (MockStateSpec('a'), '#fff', MockStateSpec(''), '#ccc')
352+
self.assertEqual(ttk._list_from_statespec(spec),
353+
[('a', '#fff'), ('', '#ccc')])
351354

352355
def test_list_from_layouttuple(self):
353356
tk = MockTkApp()

Lib/tkinter/ttk.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def _list_from_statespec(stuple):
251251
else: # this is a Tcl object
252252
val = str(val)
253253
if typename == 'StateSpec':
254-
val = val.split()
254+
val = val.split() if val else ''
255255
nval.append(val)
256256

257257
it = iter(nval)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Ammend the ttk._list_from_statespec function to correctly return the state
2+
specification for the ttk map when a default state is given.

0 commit comments

Comments
 (0)