File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed
Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change 1+ import sys
12import unittest
23from test import support
34from test .support import import_helper
4- import sys
55
66# Skip this test if the _tkinter module wasn't built.
77_tkinter = import_helper .import_module ('_tkinter' )
88
99# Skip test if tk cannot be initialized.
1010support .requires ('gui' )
1111
12- from tkinter import tix , TclError
12+ # Suppress the deprecation warning
13+ tix = import_helper .import_module ('tkinter.tix' , deprecated = True )
14+ from tkinter import TclError
1315
1416
1517class TestTix (unittest .TestCase ):
@@ -24,9 +26,12 @@ def setUp(self):
2426 else :
2527 self .addCleanup (self .root .destroy )
2628
27- def test_tix_available (self ):
28- # this test is just here to make setUp run
29- pass
29+ def test_tix_deprecation (self ):
30+ with self .assertWarns (DeprecationWarning ):
31+ import_helper .import_fresh_module (
32+ 'tkinter.tix' ,
33+ fresh = ('tkinter.tix' ,),
34+ )
3035
3136
3237if __name__ == '__main__' :
Original file line number Diff line number Diff line change 2121# Compare the demo tixwidgets.py to the original Tcl program and you will
2222# appreciate the advantages.
2323#
24+ # NOTE: This module is deprecated since Python 3.6.
2425
2526import os
27+ import warnings
2628import tkinter
2729from tkinter import *
2830from tkinter import _cnfmerge
2931
30- import _tkinter # If this fails your Python may not be configured for Tk
32+ warnings .warn (
33+ 'The Tix Tk extension is unmaintained, and the tkinter.tix wrapper module'
34+ ' is deprecated in favor of tkinter.ttk' ,
35+ DeprecationWarning ,
36+ stacklevel = 2 ,
37+ )
3138
3239# Some more constants (for consistency with Tkinter)
3340WINDOW = 'window'
Original file line number Diff line number Diff line change 1+ ``DeprecationWarning `` is now raised when importing :mod: `tkinter.tix `, which has been deprecated in documentation since Python 3.6.
You can’t perform that action at this time.
0 commit comments