Skip to content

[3.10] bpo-41730: Show deprecation warnings for tkinter.tix (GH-22186) #25971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Lib/test/test_tix.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import sys
import unittest
from test import support
from test.support import import_helper
import sys

# Skip this test if the _tkinter module wasn't built.
_tkinter = import_helper.import_module('_tkinter')

# Skip test if tk cannot be initialized.
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):
Expand All @@ -24,9 +26,12 @@ 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_deprecation(self):
with self.assertWarns(DeprecationWarning):
import_helper.import_fresh_module(
'tkinter.tix',
fresh=('tkinter.tix',),
)


if __name__ == '__main__':
Expand Down
9 changes: 8 additions & 1 deletion Lib/tkinter/tix.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@
# 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

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'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``DeprecationWarning`` is now raised when importing :mod:`tkinter.tix`, which has been deprecated in documentation since Python 3.6.