Skip to content

Commit 24cddab

Browse files
miss-islingtonXiaokang2022serhiy-storchaka
authored
[3.13] gh-128014: Fix passing default='' to the tkinter method wm_iconbitmap() (GH-128015) (GH-128418)
(cherry picked from commit 58e9f95) Co-authored-by: Zhikang Yan <[email protected]> Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent cc5b03f commit 24cddab

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

Lib/test/test_tkinter/test_misc.py

+27-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from tkinter import TclError
55
import enum
66
from test import support
7-
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest, requires_tk
7+
from test.test_tkinter.support import (AbstractTkTest, AbstractDefaultRootTest,
8+
requires_tk, get_tk_patchlevel)
89

910
support.requires('gui')
1011

@@ -540,6 +541,31 @@ def test_wm_attribute(self):
540541
self.assertEqual(w.wm_attributes('alpha'),
541542
1.0 if self.wantobjects else '1.0')
542543

544+
def test_wm_iconbitmap(self):
545+
t = tkinter.Toplevel(self.root)
546+
self.assertEqual(t.wm_iconbitmap(), '')
547+
t.wm_iconbitmap('hourglass')
548+
bug = False
549+
if t._windowingsystem == 'aqua':
550+
# Tk bug 13ac26b35dc55f7c37f70b39d59d7ef3e63017c8.
551+
patchlevel = get_tk_patchlevel(t)
552+
if patchlevel < (8, 6, 17) or (9, 0) <= patchlevel < (9, 0, 2):
553+
bug = True
554+
if not bug:
555+
self.assertEqual(t.wm_iconbitmap(), 'hourglass')
556+
self.assertEqual(self.root.wm_iconbitmap(), '')
557+
t.wm_iconbitmap('')
558+
self.assertEqual(t.wm_iconbitmap(), '')
559+
560+
if t._windowingsystem == 'win32':
561+
t.wm_iconbitmap(default='hourglass')
562+
self.assertEqual(t.wm_iconbitmap(), 'hourglass')
563+
self.assertEqual(self.root.wm_iconbitmap(), '')
564+
t.wm_iconbitmap(default='')
565+
self.assertEqual(t.wm_iconbitmap(), '')
566+
567+
t.destroy()
568+
543569

544570
class EventTest(AbstractTkTest, unittest.TestCase):
545571

Lib/tkinter/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2263,7 +2263,7 @@ def wm_iconbitmap(self, bitmap=None, default=None):
22632263
explicitly. DEFAULT can be the relative path to a .ico file
22642264
(example: root.iconbitmap(default='myicon.ico') ). See Tk
22652265
documentation for more information."""
2266-
if default:
2266+
if default is not None:
22672267
return self.tk.call('wm', 'iconbitmap', self._w, '-default', default)
22682268
else:
22692269
return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix resetting the default window icon by passing ``default=''`` to the
2+
:mod:`tkinter` method :meth:`!wm_iconbitmap`.

0 commit comments

Comments
 (0)