How Do I ............?

Jason Swails jason.swails at gmail.com
Fri Jul 31 22:22:36 EDT 2015


On Fri, Jul 31, 2015 at 9:21 PM, Steve Burrus <steveburrus28 at gmail.com>
wrote:

> How Do I access tkinter in Python 3.4 anyway? I've tried and  tried but
> cannot do it.
>

​You import it.

If I play mind-reader for a second, I suspect you're trying to do in Python
3 what you did in Python 2.  That won't work -- the Tkinter module layout
has completely changed between Python 2 and Python 3.  For starters,
instead of doing:

import Tkinter

like you did in Python 2, you need to do

import tkinter

in Python 3.  There are several other changes, like standalone modules that
are not subpackages in tkinter (e.g., tkMessageBox is now
tkinter.messagebox).  To get a more complete list of name changes, you can
Google something like "tkinter python 2 to python 3", which will give you a
page like this:
http://docs.pythonsprints.com/python3_porting/py-porting.html.

Personally, I don't bother with that.  I have my working Tkinter code from
Python 2 and simply look at what the "2to3" module spits out during its
conversion.  That's often a good way to figure out "how the heck do I do
something in Python 3" when you have a script written for Python 2 that
works.

If that doesn't answer your question, then chances are your Python wasn't
built with Tkinter support (like the system Pythons in many Linux
distributions).  In that case you need to install the appropriate package
(depends on your distro).

​Or if that *still* doesn't answer your question, then provide enough
information so that someone can actually figure out what went wrong ;).​

HTH,
Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150731/17e8170e/attachment.html>


More information about the Python-list mailing list