mirror of
https://github.com/python/cpython.git
synced 2025-08-02 08:02:56 +00:00
bpo-41730: Show deprecation warnings for tkinter.tix (GH-22186)
Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com> Co-authored-by: Zachary Ware <zach@python.org>
This commit is contained in:
parent
adcd220556
commit
4a2d98a1e9
3 changed files with 19 additions and 6 deletions
|
@ -1,7 +1,7 @@
|
||||||
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
from test import support
|
from test import support
|
||||||
from test.support import import_helper
|
from test.support import import_helper
|
||||||
import sys
|
|
||||||
|
|
||||||
# Skip this test if the _tkinter module wasn't built.
|
# Skip this test if the _tkinter module wasn't built.
|
||||||
_tkinter = import_helper.import_module('_tkinter')
|
_tkinter = import_helper.import_module('_tkinter')
|
||||||
|
@ -9,7 +9,9 @@ _tkinter = import_helper.import_module('_tkinter')
|
||||||
# Skip test if tk cannot be initialized.
|
# Skip test if tk cannot be initialized.
|
||||||
support.requires('gui')
|
support.requires('gui')
|
||||||
|
|
||||||
from tkinter import tix, TclError
|
# Suppress the deprecation warning
|
||||||
|
tix = import_helper.import_module('tkinter.tix', deprecated=True)
|
||||||
|
from tkinter import TclError
|
||||||
|
|
||||||
|
|
||||||
class TestTix(unittest.TestCase):
|
class TestTix(unittest.TestCase):
|
||||||
|
@ -24,9 +26,12 @@ class TestTix(unittest.TestCase):
|
||||||
else:
|
else:
|
||||||
self.addCleanup(self.root.destroy)
|
self.addCleanup(self.root.destroy)
|
||||||
|
|
||||||
def test_tix_available(self):
|
def test_tix_deprecation(self):
|
||||||
# this test is just here to make setUp run
|
with self.assertWarns(DeprecationWarning):
|
||||||
pass
|
import_helper.import_fresh_module(
|
||||||
|
'tkinter.tix',
|
||||||
|
fresh=('tkinter.tix',),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -21,13 +21,20 @@
|
||||||
# Compare the demo tixwidgets.py to the original Tcl program and you will
|
# Compare the demo tixwidgets.py to the original Tcl program and you will
|
||||||
# appreciate the advantages.
|
# appreciate the advantages.
|
||||||
#
|
#
|
||||||
|
# NOTE: This module is deprecated since Python 3.6.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import warnings
|
||||||
import tkinter
|
import tkinter
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
from tkinter import _cnfmerge
|
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)
|
# Some more constants (for consistency with Tkinter)
|
||||||
WINDOW = 'window'
|
WINDOW = 'window'
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
``DeprecationWarning`` is now raised when importing :mod:`tkinter.tix`, which has been deprecated in documentation since Python 3.6.
|
Loading…
Add table
Add a link
Reference in a new issue