From 32e8c9ccab17f43f6e703da6063300ac937242bd Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Thu, 10 Sep 2020 19:08:10 +0800 Subject: [PATCH 01/18] bpo-41730: Show deprecation warnings for tkinter.tix --- Lib/tkinter/tix.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Lib/tkinter/tix.py b/Lib/tkinter/tix.py index ac545502e45c30..e9059974e9505c 100644 --- a/Lib/tkinter/tix.py +++ b/Lib/tkinter/tix.py @@ -13,16 +13,18 @@ # inheritance of base classes. # # As a result after creating a 'w = StdButtonBox', I can write -# w.ok['text'] = 'Who Cares' -# or w.ok['bg'] = w['bg'] +# w.ok['text'] = 'Who Cares' +# or w.ok['bg'] = w['bg'] # or even w.ok.invoke() # etc. # # Compare the demo tixwidgets.py to the original Tcl program and you will # appreciate the advantages. # +# NOTE: This module is deprecated since Python 3.6. import os +import warnings import tkinter from tkinter import * from tkinter import _cnfmerge @@ -63,6 +65,10 @@ TCL_IDLE_EVENTS = 1 << 5 TCL_ALL_EVENTS = 0 +# Deprecation warning +warnings.warn('the tkinter.tix module is deprecated in favour of tkinter.ttk and is set \ +to be removed in the near-future.', DeprecationWarning, stacklevel=2) + # BEWARE - this is implemented by copying some code from the Widget class # in Tkinter (to override Widget initialization) and is therefore # liable to break. From 897b6045e29af8df9738287c05b6c342aafd3278 Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Thu, 10 Sep 2020 19:18:44 +0800 Subject: [PATCH 02/18] bpo-41730: Show deprecation warnings for tkinter.tix --- .../NEWS.d/next/Library/2020-09-10-07-16-27.bpo-41370.DyKFi9.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2020-09-10-07-16-27.bpo-41370.DyKFi9.rst diff --git a/Misc/NEWS.d/next/Library/2020-09-10-07-16-27.bpo-41370.DyKFi9.rst b/Misc/NEWS.d/next/Library/2020-09-10-07-16-27.bpo-41370.DyKFi9.rst new file mode 100644 index 00000000000000..df81221f9e1c7d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-09-10-07-16-27.bpo-41370.DyKFi9.rst @@ -0,0 +1 @@ +The ``tkinter.ttk`` module has been deprecated since Python 3.6. Warn a ``DeprecationWarning`` when importing it. From ce41fbe8da4b4ca162479d8faff4b0ecf38dfcea Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Thu, 10 Sep 2020 19:24:03 +0800 Subject: [PATCH 03/18] bpo-41730: Show deprecation warnings for tkinter.tix --- .../NEWS.d/next/Library/2020-09-10-07-16-27.bpo-41370.DyKFi9.rst | 1 - .../NEWS.d/next/Library/2020-09-10-07-23-24.bpo-41730.DyKFi9.rst | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Library/2020-09-10-07-16-27.bpo-41370.DyKFi9.rst create mode 100644 Misc/NEWS.d/next/Library/2020-09-10-07-23-24.bpo-41730.DyKFi9.rst diff --git a/Misc/NEWS.d/next/Library/2020-09-10-07-16-27.bpo-41370.DyKFi9.rst b/Misc/NEWS.d/next/Library/2020-09-10-07-16-27.bpo-41370.DyKFi9.rst deleted file mode 100644 index df81221f9e1c7d..00000000000000 --- a/Misc/NEWS.d/next/Library/2020-09-10-07-16-27.bpo-41370.DyKFi9.rst +++ /dev/null @@ -1 +0,0 @@ -The ``tkinter.ttk`` module has been deprecated since Python 3.6. Warn a ``DeprecationWarning`` when importing it. diff --git a/Misc/NEWS.d/next/Library/2020-09-10-07-23-24.bpo-41730.DyKFi9.rst b/Misc/NEWS.d/next/Library/2020-09-10-07-23-24.bpo-41730.DyKFi9.rst new file mode 100644 index 00000000000000..fd32c6b885344b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-09-10-07-23-24.bpo-41730.DyKFi9.rst @@ -0,0 +1 @@ +The ``tkinter.tix`` module has been deprecated since Python 3.6. Warn a ``DeprecationWarning`` when importing it. From 21f079917f624d966cc9319123e4fa431e371514 Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Thu, 10 Sep 2020 19:25:56 +0800 Subject: [PATCH 04/18] bpo-41730: Show deprecation warnings for tkinter.tix --- Lib/tkinter/tix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/tkinter/tix.py b/Lib/tkinter/tix.py index e9059974e9505c..2915b3710081aa 100644 --- a/Lib/tkinter/tix.py +++ b/Lib/tkinter/tix.py @@ -67,7 +67,7 @@ # Deprecation warning warnings.warn('the tkinter.tix module is deprecated in favour of tkinter.ttk and is set \ -to be removed in the near-future.', DeprecationWarning, stacklevel=2) +to be removed in the near-future', DeprecationWarning, stacklevel=2) # BEWARE - this is implemented by copying some code from the Widget class # in Tkinter (to override Widget initialization) and is therefore From 44565dfac11c7e7774eea6dbb8ab2165fd344c66 Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Thu, 10 Sep 2020 19:51:24 +0800 Subject: [PATCH 05/18] bpo-41730: Show deprecation warnings for tkinter.tix Suggested by @E-Paine Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com> --- Lib/tkinter/tix.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/tkinter/tix.py b/Lib/tkinter/tix.py index 2915b3710081aa..f2eadbb7bf8828 100644 --- a/Lib/tkinter/tix.py +++ b/Lib/tkinter/tix.py @@ -66,8 +66,8 @@ TCL_ALL_EVENTS = 0 # Deprecation warning -warnings.warn('the tkinter.tix module is deprecated in favour of tkinter.ttk and is set \ -to be removed in the near-future', DeprecationWarning, stacklevel=2) +warnings.warn('the tkinter.tix module is deprecated in favour of tkinter.ttk and is set ' + 'to be removed in the near-future', DeprecationWarning, stacklevel=2) # BEWARE - this is implemented by copying some code from the Widget class # in Tkinter (to override Widget initialization) and is therefore From 97b6ff1298740f9a950b60a7af02f994b9ed9528 Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Wed, 17 Mar 2021 19:41:30 +0800 Subject: [PATCH 06/18] Update Misc/NEWS.d/next/Library/2020-09-10-07-23-24.bpo-41730.DyKFi9.rst Co-authored-by: Zachary Ware --- .../next/Library/2020-09-10-07-23-24.bpo-41730.DyKFi9.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2020-09-10-07-23-24.bpo-41730.DyKFi9.rst b/Misc/NEWS.d/next/Library/2020-09-10-07-23-24.bpo-41730.DyKFi9.rst index fd32c6b885344b..63d8353a7aab2e 100644 --- a/Misc/NEWS.d/next/Library/2020-09-10-07-23-24.bpo-41730.DyKFi9.rst +++ b/Misc/NEWS.d/next/Library/2020-09-10-07-23-24.bpo-41730.DyKFi9.rst @@ -1 +1 @@ -The ``tkinter.tix`` module has been deprecated since Python 3.6. Warn a ``DeprecationWarning`` when importing it. +``DeprecationWarning`` is now raised when importing :mod:`tkinter.tix`, which has been deprecated in documentation since Python 3.6. From e2767f52dd82c41465e5a8d6747dc38e0d3f898b Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Sat, 27 Mar 2021 13:15:34 +0800 Subject: [PATCH 07/18] Update Lib/tkinter/tix.py Co-authored-by: Zachary Ware --- Lib/tkinter/tix.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/tkinter/tix.py b/Lib/tkinter/tix.py index f2eadbb7bf8828..16d613cf1fb0e7 100644 --- a/Lib/tkinter/tix.py +++ b/Lib/tkinter/tix.py @@ -65,7 +65,6 @@ TCL_IDLE_EVENTS = 1 << 5 TCL_ALL_EVENTS = 0 -# Deprecation warning warnings.warn('the tkinter.tix module is deprecated in favour of tkinter.ttk and is set ' 'to be removed in the near-future', DeprecationWarning, stacklevel=2) From 9e318e883a3329857877cd04ab99a568be999ee2 Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Sat, 27 Mar 2021 13:47:52 +0800 Subject: [PATCH 08/18] bpo-41730: Deprecate tkinter.tix --- Lib/tkinter/tix.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/tkinter/tix.py b/Lib/tkinter/tix.py index 16d613cf1fb0e7..831040c0900bab 100644 --- a/Lib/tkinter/tix.py +++ b/Lib/tkinter/tix.py @@ -65,8 +65,8 @@ TCL_IDLE_EVENTS = 1 << 5 TCL_ALL_EVENTS = 0 -warnings.warn('the tkinter.tix module is deprecated in favour of tkinter.ttk and is set ' - 'to be removed in the near-future', DeprecationWarning, stacklevel=2) +warnings.warn('The Tix Tk extension is unmaintained, and the tkinter.tix wrapper is deprecated in ' + 'favour of tkinter.ttk', DeprecationWarning, stacklevel=2) # BEWARE - this is implemented by copying some code from the Widget class # in Tkinter (to override Widget initialization) and is therefore From b51644cf99012886682e871bf58f5873a605e801 Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Thu, 6 May 2021 23:50:25 +0800 Subject: [PATCH 09/18] Update Lib/tkinter/tix.py Co-authored-by: Zachary Ware --- Lib/tkinter/tix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/tkinter/tix.py b/Lib/tkinter/tix.py index 831040c0900bab..29f6f3b0e9aa18 100644 --- a/Lib/tkinter/tix.py +++ b/Lib/tkinter/tix.py @@ -66,7 +66,7 @@ TCL_ALL_EVENTS = 0 warnings.warn('The Tix Tk extension is unmaintained, and the tkinter.tix wrapper is deprecated in ' - 'favour of tkinter.ttk', DeprecationWarning, stacklevel=2) + 'favor of tkinter.ttk', DeprecationWarning, stacklevel=2) # BEWARE - this is implemented by copying some code from the Widget class # in Tkinter (to override Widget initialization) and is therefore From 7087f298b8f8cba1025684047d91f64e83358dd8 Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Thu, 6 May 2021 23:55:31 +0800 Subject: [PATCH 10/18] bpo-41730: Show warning for deprecated tkinter.tix --- Lib/tkinter/tix.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/tkinter/tix.py b/Lib/tkinter/tix.py index 29f6f3b0e9aa18..2976f92be897ea 100644 --- a/Lib/tkinter/tix.py +++ b/Lib/tkinter/tix.py @@ -13,8 +13,8 @@ # inheritance of base classes. # # As a result after creating a 'w = StdButtonBox', I can write -# w.ok['text'] = 'Who Cares' -# or w.ok['bg'] = w['bg'] +# w.ok['text'] = 'Who Cares' +# or w.ok['bg'] = w['bg'] # or even w.ok.invoke() # etc. # From 18496cd418eeafd398847cf05c3afa3c13da5e89 Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Fri, 7 May 2021 17:34:47 +0800 Subject: [PATCH 11/18] bpo-41730: Update tkinter.tix test --- Lib/test/test_tix.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_tix.py b/Lib/test/test_tix.py index e6d759e7bd3b61..0164f696b693a6 100644 --- a/Lib/test/test_tix.py +++ b/Lib/test/test_tix.py @@ -2,6 +2,7 @@ from test import support from test.support import import_helper import sys +import warnings # Skip this test if the _tkinter module wasn't built. _tkinter = import_helper.import_module('_tkinter') @@ -9,7 +10,9 @@ # Skip test if tk cannot be initialized. support.requires('gui') -from tkinter import tix, TclError +with warnings.catch_warnings(): + from tkinter import tix +from tkinter import TclError class TestTix(unittest.TestCase): @@ -24,9 +27,9 @@ def setUp(self): else: self.addCleanup(self.root.destroy) - def test_tix_available(self): - # this test is just here to make setUp run - pass + def test_tix_warning(self): + with self.assertWarns(DeprecationWarning): + from tkinter import tix if __name__ == '__main__': From d0fbf5d5d5e4b76781d19cd157c92aa1c40026fb Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Fri, 7 May 2021 21:04:22 +0800 Subject: [PATCH 12/18] Update test_tix.py --- Lib/test/test_tix.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_tix.py b/Lib/test/test_tix.py index 0164f696b693a6..3859d9728a3f51 100644 --- a/Lib/test/test_tix.py +++ b/Lib/test/test_tix.py @@ -10,8 +10,9 @@ # Skip test if tk cannot be initialized. support.requires('gui') -with warnings.catch_warnings(): - from tkinter import tix +warnings.simplefilter('ignore', DeprecationWarning) +from tkinter import tix +warnings.simplefilter('always', DeprecationWarning) from tkinter import TclError From 4f87da779862c39126a169e6a4fde3865ee9dd45 Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Fri, 7 May 2021 23:03:44 +0800 Subject: [PATCH 13/18] bpo-41730: Update Tix tests --- Lib/test/test_tix.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_tix.py b/Lib/test/test_tix.py index 3859d9728a3f51..52134c104b5668 100644 --- a/Lib/test/test_tix.py +++ b/Lib/test/test_tix.py @@ -10,9 +10,7 @@ # Skip test if tk cannot be initialized. support.requires('gui') -warnings.simplefilter('ignore', DeprecationWarning) -from tkinter import tix -warnings.simplefilter('always', DeprecationWarning) +tix = support.import_module('tkinter.tix', deprecated=True) from tkinter import TclError @@ -29,6 +27,8 @@ def setUp(self): self.addCleanup(self.root.destroy) def test_tix_warning(self): + support.import_fresh_module('tkinter.tix', fresh=('tkinter.tix',)) + # Refresh module to issue warning with self.assertWarns(DeprecationWarning): from tkinter import tix From f71a81d86b7d0b900fe2be35f86325a4f95de0d8 Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Fri, 7 May 2021 23:07:17 +0800 Subject: [PATCH 14/18] bpo-41730: Update Tix tests --- Lib/test/test_tix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_tix.py b/Lib/test/test_tix.py index 52134c104b5668..609db8c9d3f1eb 100644 --- a/Lib/test/test_tix.py +++ b/Lib/test/test_tix.py @@ -10,7 +10,7 @@ # Skip test if tk cannot be initialized. support.requires('gui') -tix = support.import_module('tkinter.tix', deprecated=True) +tix = import_helper.import_module('tkinter.tix', deprecated=True) from tkinter import TclError From cf3da54bcc8faa5f3402f1f0b1d811acbb4f5f48 Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Fri, 7 May 2021 23:09:42 +0800 Subject: [PATCH 15/18] bpo-41730: Update Tix tests --- Lib/test/test_tix.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_tix.py b/Lib/test/test_tix.py index 609db8c9d3f1eb..a98314e06d52cb 100644 --- a/Lib/test/test_tix.py +++ b/Lib/test/test_tix.py @@ -5,7 +5,7 @@ import warnings # Skip this test if the _tkinter module wasn't built. -_tkinter = import_helper.import_module('_tkinter') +_tkinter = support.import_module('_tkinter') # Skip test if tk cannot be initialized. support.requires('gui') @@ -27,10 +27,9 @@ def setUp(self): self.addCleanup(self.root.destroy) def test_tix_warning(self): - support.import_fresh_module('tkinter.tix', fresh=('tkinter.tix',)) # Refresh module to issue warning with self.assertWarns(DeprecationWarning): - from tkinter import tix + tix = support.import_fresh_module('tkinter.tix', fresh=('tkinter.tix',)) if __name__ == '__main__': From 976f5f9aa1a32eb2dd4bb66c658c57fb05a1c4c3 Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Fri, 7 May 2021 23:11:46 +0800 Subject: [PATCH 16/18] bpo-41730: Issue warning for deprecated Tix --- Lib/tkinter/tix.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/tkinter/tix.py b/Lib/tkinter/tix.py index 2976f92be897ea..27ecd096ce94f6 100644 --- a/Lib/tkinter/tix.py +++ b/Lib/tkinter/tix.py @@ -65,7 +65,8 @@ TCL_IDLE_EVENTS = 1 << 5 TCL_ALL_EVENTS = 0 -warnings.warn('The Tix Tk extension is unmaintained, and the tkinter.tix wrapper is deprecated in ' +warnings.warn('The Tix Tk extension is unmaintained, ' + 'and the tkinter.tix wrapper is deprecated in ' 'favor of tkinter.ttk', DeprecationWarning, stacklevel=2) # BEWARE - this is implemented by copying some code from the Widget class From ca233ab146cfe1da71a8a7fa09f3bf3a6c9ec1b1 Mon Sep 17 00:00:00 2001 From: wyz23x2 <52805709+wyz23x2@users.noreply.github.com> Date: Fri, 7 May 2021 23:31:54 +0800 Subject: [PATCH 17/18] Update test_tix.py --- Lib/test/test_tix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_tix.py b/Lib/test/test_tix.py index a98314e06d52cb..4f807987a157fd 100644 --- a/Lib/test/test_tix.py +++ b/Lib/test/test_tix.py @@ -5,7 +5,7 @@ import warnings # Skip this test if the _tkinter module wasn't built. -_tkinter = support.import_module('_tkinter') +_tkinter = import_helper.import_module('_tkinter') # Skip test if tk cannot be initialized. support.requires('gui') From 9602a7c4fdb033b96d250b114f9a7d06b9d4fea7 Mon Sep 17 00:00:00 2001 From: Zachary Ware Date: Fri, 7 May 2021 10:34:02 -0500 Subject: [PATCH 18/18] Cleanups --- Lib/test/test_tix.py | 12 +++++++----- Lib/tkinter/tix.py | 11 ++++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Lib/test/test_tix.py b/Lib/test/test_tix.py index 4f807987a157fd..a2fb357fd0c500 100644 --- a/Lib/test/test_tix.py +++ b/Lib/test/test_tix.py @@ -1,8 +1,7 @@ +import sys import unittest from test import support from test.support import import_helper -import sys -import warnings # Skip this test if the _tkinter module wasn't built. _tkinter = import_helper.import_module('_tkinter') @@ -10,6 +9,7 @@ # Skip test if tk cannot be initialized. support.requires('gui') +# Suppress the deprecation warning tix = import_helper.import_module('tkinter.tix', deprecated=True) from tkinter import TclError @@ -26,10 +26,12 @@ def setUp(self): else: self.addCleanup(self.root.destroy) - def test_tix_warning(self): - # Refresh module to issue warning + def test_tix_deprecation(self): with self.assertWarns(DeprecationWarning): - tix = support.import_fresh_module('tkinter.tix', fresh=('tkinter.tix',)) + import_helper.import_fresh_module( + 'tkinter.tix', + fresh=('tkinter.tix',), + ) if __name__ == '__main__': diff --git a/Lib/tkinter/tix.py b/Lib/tkinter/tix.py index 27ecd096ce94f6..f39de747b8fb56 100644 --- a/Lib/tkinter/tix.py +++ b/Lib/tkinter/tix.py @@ -29,7 +29,12 @@ from tkinter import * from tkinter import _cnfmerge -import _tkinter # If this fails your Python may not be configured for Tk +warnings.warn( + 'The Tix Tk extension is unmaintained, and the tkinter.tix wrapper module' + ' is deprecated in favor of tkinter.ttk', + DeprecationWarning, + stacklevel=2, + ) # Some more constants (for consistency with Tkinter) WINDOW = 'window' @@ -65,10 +70,6 @@ TCL_IDLE_EVENTS = 1 << 5 TCL_ALL_EVENTS = 0 -warnings.warn('The Tix Tk extension is unmaintained, ' - 'and the tkinter.tix wrapper is deprecated in ' - 'favor of tkinter.ttk', DeprecationWarning, stacklevel=2) - # BEWARE - this is implemented by copying some code from the Widget class # in Tkinter (to override Widget initialization) and is therefore # liable to break.