Closed
Description
Hello,
The tkinter package included here does a from Tkinter import *
, which misses at least _flatten
, and _cnfmerge
which might be used by tk extensions. Therefore the typical method of handling Python 2/3 causes it to stop working when combined with python-future. Example:
try:
import tkinter
except ImportError:
import Tkinter as tkinter
after running the above on stock Python 2 or Python 3 tkinter._flatten
is available, but not when using python-future. Packages that make use of that need to be patched with something like:
if not hasattr(tkinter, '_flatten'):
from Tkinter import _flatten, _cnfmerge
tkinter._flatten = _flatten
tkinter._cnfmerge = _cnfmerge
Activity
edschofield commentedon Sep 21, 2016
Thanks for the feedback, Guilherme!
I have added _flatten and _cnfmerge to the v0.16.x branch.
I would be very grateful if you could provide me with a comprehensive list of other underscore-prefixed names that deserve to be added. We could add these to the upcoming v0.16 release.
gpip commentedon Sep 22, 2016
I believe the full list is
['_cnfmerge', '_default_root', '_exit', '_flatten', '_join', '_magic_re', '_setit', '_space_re', '_splitdict', '_stringify', '_support_default_root', '_test', '_tkerror', '_tkinter', '_varnum']
. It's safer to add them all, but I would guess that_magic_re
,_space_re
, probably_exit
and_tkerror
, and_varnum
are not/should not be in public use. The "semi-safe" list would then be:['_cnfmerge', '_default_root', '_flatten', '_join', '_setit', '_splitdict', '_stringify', '_support_default_root', '_test', '_tkinter']
Add _flatten and _cnfmerge to tkinter package (issue #233)
Add more underscore-prefixed imports to `tkinter` (issue #233)
edschofield commentedon Oct 27, 2016
I think this is fixed now in v0.16.0. Please feel free to re-open this issue if you encounter any more missing
_names
.tkinter
in Python 2.7 #262alkrag commentedon Jul 20, 2023
I had the problem - I tried the above - For me the issue was I had installed a newer version of Anaconda without deleting the earlier - It had always worked before - It worked on other computers - When I deleted the earlier versions, it worked again - Not sure if that's related...