mirror of
https://github.com/python/cpython.git
synced 2025-08-10 20:08:47 +00:00
[3.12] gh-128014: Fix passing default='' to the tkinter method wm_iconbitmap() (GH-128015) (GH-128420)
(cherry picked from commit 58e9f95c4a
)
Co-authored-by: Zhikang Yan <2951256653@qq.com>
This commit is contained in:
parent
52c08ed029
commit
7ce09fc93b
3 changed files with 33 additions and 2 deletions
|
@ -3,7 +3,8 @@ import unittest
|
||||||
import tkinter
|
import tkinter
|
||||||
import enum
|
import enum
|
||||||
from test import support
|
from test import support
|
||||||
from test.test_tkinter.support import AbstractTkTest, AbstractDefaultRootTest
|
from test.test_tkinter.support import (AbstractTkTest, AbstractDefaultRootTest,
|
||||||
|
requires_tk, get_tk_patchlevel)
|
||||||
|
|
||||||
support.requires('gui')
|
support.requires('gui')
|
||||||
|
|
||||||
|
@ -392,6 +393,34 @@ class MiscTest(AbstractTkTest, unittest.TestCase):
|
||||||
self.assertEqual(widget.selection_get(), '\u20ac\0abc\x00def')
|
self.assertEqual(widget.selection_get(), '\u20ac\0abc\x00def')
|
||||||
|
|
||||||
|
|
||||||
|
class WmTest(AbstractTkTest, unittest.TestCase):
|
||||||
|
|
||||||
|
def test_wm_iconbitmap(self):
|
||||||
|
t = tkinter.Toplevel(self.root)
|
||||||
|
self.assertEqual(t.wm_iconbitmap(), '')
|
||||||
|
t.wm_iconbitmap('hourglass')
|
||||||
|
bug = False
|
||||||
|
if t._windowingsystem == 'aqua':
|
||||||
|
# Tk bug 13ac26b35dc55f7c37f70b39d59d7ef3e63017c8.
|
||||||
|
patchlevel = get_tk_patchlevel(t)
|
||||||
|
if patchlevel < (8, 6, 17) or (9, 0) <= patchlevel < (9, 0, 2):
|
||||||
|
bug = True
|
||||||
|
if not bug:
|
||||||
|
self.assertEqual(t.wm_iconbitmap(), 'hourglass')
|
||||||
|
self.assertEqual(self.root.wm_iconbitmap(), '')
|
||||||
|
t.wm_iconbitmap('')
|
||||||
|
self.assertEqual(t.wm_iconbitmap(), '')
|
||||||
|
|
||||||
|
if t._windowingsystem == 'win32':
|
||||||
|
t.wm_iconbitmap(default='hourglass')
|
||||||
|
self.assertEqual(t.wm_iconbitmap(), 'hourglass')
|
||||||
|
self.assertEqual(self.root.wm_iconbitmap(), '')
|
||||||
|
t.wm_iconbitmap(default='')
|
||||||
|
self.assertEqual(t.wm_iconbitmap(), '')
|
||||||
|
|
||||||
|
t.destroy()
|
||||||
|
|
||||||
|
|
||||||
class EventTest(AbstractTkTest, unittest.TestCase):
|
class EventTest(AbstractTkTest, unittest.TestCase):
|
||||||
|
|
||||||
def test_focus(self):
|
def test_focus(self):
|
||||||
|
|
|
@ -2150,7 +2150,7 @@ class Wm:
|
||||||
explicitly. DEFAULT can be the relative path to a .ico file
|
explicitly. DEFAULT can be the relative path to a .ico file
|
||||||
(example: root.iconbitmap(default='myicon.ico') ). See Tk
|
(example: root.iconbitmap(default='myicon.ico') ). See Tk
|
||||||
documentation for more information."""
|
documentation for more information."""
|
||||||
if default:
|
if default is not None:
|
||||||
return self.tk.call('wm', 'iconbitmap', self._w, '-default', default)
|
return self.tk.call('wm', 'iconbitmap', self._w, '-default', default)
|
||||||
else:
|
else:
|
||||||
return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
|
return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix resetting the default window icon by passing ``default=''`` to the
|
||||||
|
:mod:`tkinter` method :meth:`!wm_iconbitmap`.
|
Loading…
Add table
Add a link
Reference in a new issue