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
1
2
import unittest
2
3
from test import support
3
4
from test .support import import_helper
4
- import sys
5
5
6
6
# Skip this test if the _tkinter module wasn't built.
7
7
_tkinter = import_helper .import_module ('_tkinter' )
8
8
9
9
# Skip test if tk cannot be initialized.
10
10
support .requires ('gui' )
11
11
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
13
15
14
16
15
17
class TestTix (unittest .TestCase ):
@@ -24,9 +26,12 @@ def setUp(self):
24
26
else :
25
27
self .addCleanup (self .root .destroy )
26
28
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
+ )
30
35
31
36
32
37
if __name__ == '__main__' :
Original file line number Diff line number Diff line change 21
21
# Compare the demo tixwidgets.py to the original Tcl program and you will
22
22
# appreciate the advantages.
23
23
#
24
+ # NOTE: This module is deprecated since Python 3.6.
24
25
25
26
import os
27
+ import warnings
26
28
import tkinter
27
29
from tkinter import *
28
30
from tkinter import _cnfmerge
29
31
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
+ )
31
38
32
39
# Some more constants (for consistency with Tkinter)
33
40
WINDOW = '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