You are not logged in.

#1 2020-11-03 10:06:49

dauriac
Member
Registered: 2019-01-29
Posts: 39

Tkinter with python3 [SOLVED]

Hello
I installed tkinter with

sudo pacman -S tk

.
As a result the module Tkinter is located at  /usr/lib/python2.7/lib-tk/Tkinter.py, and everything is fine with python2.7
I am now switching to python3.x and so I cannot use anymore the module Tkinter.
How to intall Tkinter for python3.x ?
Thanks

Last edited by dauriac (2020-11-03 10:29:38)

Offline

#2 2020-11-03 10:13:06

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 18,212

Re: Tkinter with python3 [SOLVED]

The tkinter integration is part of the python2 and the python package respectively. What does "can't use anymore" mean exactly?

pacman -Ql python | grep tk
python /usr/lib/python3.8/idlelib/Icons/tk.gif
python /usr/lib/python3.8/lib-dynload/_tkinter.cpython-38-x86_64-linux-gnu.so
python /usr/lib/python3.8/tkinter/
python /usr/lib/python3.8/tkinter/__init__.py
python /usr/lib/python3.8/tkinter/__main__.py
python /usr/lib/python3.8/tkinter/__pycache__/
python /usr/lib/python3.8/tkinter/__pycache__/__init__.cpython-38.opt-1.pyc
python /usr/lib/python3.8/tkinter/__pycache__/__init__.cpython-38.opt-2.pyc
python /usr/lib/python3.8/tkinter/__pycache__/__init__.cpython-38.pyc
python /usr/lib/python3.8/tkinter/__pycache__/__main__.cpython-38.opt-1.pyc
python /usr/lib/python3.8/tkinter/__pycache__/__main__.cpython-38.opt-2.pyc
python /usr/lib/python3.8/tkinter/__pycache__/__main__.cpython-38.pyc
python /usr/lib/python3.8/tkinter/__pycache__/colorchooser.cpython-38.opt-1.pyc
python /usr/lib/python3.8/tkinter/__pycache__/colorchooser.cpython-38.opt-2.pyc
python /usr/lib/python3.8/tkinter/__pycache__/colorchooser.cpython-38.pyc
python /usr/lib/python3.8/tkinter/__pycache__/commondialog.cpython-38.opt-1.pyc
python /usr/lib/python3.8/tkinter/__pycache__/commondialog.cpython-38.opt-2.pyc
python /usr/lib/python3.8/tkinter/__pycache__/commondialog.cpython-38.pyc
python /usr/lib/python3.8/tkinter/__pycache__/constants.cpython-38.opt-1.pyc
python /usr/lib/python3.8/tkinter/__pycache__/constants.cpython-38.opt-2.pyc
python /usr/lib/python3.8/tkinter/__pycache__/constants.cpython-38.pyc
python /usr/lib/python3.8/tkinter/__pycache__/dialog.cpython-38.opt-1.pyc
python /usr/lib/python3.8/tkinter/__pycache__/dialog.cpython-38.opt-2.pyc
python /usr/lib/python3.8/tkinter/__pycache__/dialog.cpython-38.pyc
python /usr/lib/python3.8/tkinter/__pycache__/dnd.cpython-38.opt-1.pyc
python /usr/lib/python3.8/tkinter/__pycache__/dnd.cpython-38.opt-2.pyc
python /usr/lib/python3.8/tkinter/__pycache__/dnd.cpython-38.pyc
python /usr/lib/python3.8/tkinter/__pycache__/filedialog.cpython-38.opt-1.pyc
python /usr/lib/python3.8/tkinter/__pycache__/filedialog.cpython-38.opt-2.pyc
python /usr/lib/python3.8/tkinter/__pycache__/filedialog.cpython-38.pyc
python /usr/lib/python3.8/tkinter/__pycache__/font.cpython-38.opt-1.pyc
python /usr/lib/python3.8/tkinter/__pycache__/font.cpython-38.opt-2.pyc
python /usr/lib/python3.8/tkinter/__pycache__/font.cpython-38.pyc
python /usr/lib/python3.8/tkinter/__pycache__/messagebox.cpython-38.opt-1.pyc
python /usr/lib/python3.8/tkinter/__pycache__/messagebox.cpython-38.opt-2.pyc
python /usr/lib/python3.8/tkinter/__pycache__/messagebox.cpython-38.pyc
python /usr/lib/python3.8/tkinter/__pycache__/scrolledtext.cpython-38.opt-1.pyc
python /usr/lib/python3.8/tkinter/__pycache__/scrolledtext.cpython-38.opt-2.pyc
python /usr/lib/python3.8/tkinter/__pycache__/scrolledtext.cpython-38.pyc
python /usr/lib/python3.8/tkinter/__pycache__/simpledialog.cpython-38.opt-1.pyc
python /usr/lib/python3.8/tkinter/__pycache__/simpledialog.cpython-38.opt-2.pyc
python /usr/lib/python3.8/tkinter/__pycache__/simpledialog.cpython-38.pyc
python /usr/lib/python3.8/tkinter/__pycache__/tix.cpython-38.opt-1.pyc
python /usr/lib/python3.8/tkinter/__pycache__/tix.cpython-38.opt-2.pyc
python /usr/lib/python3.8/tkinter/__pycache__/tix.cpython-38.pyc
python /usr/lib/python3.8/tkinter/__pycache__/ttk.cpython-38.opt-1.pyc
python /usr/lib/python3.8/tkinter/__pycache__/ttk.cpython-38.opt-2.pyc
python /usr/lib/python3.8/tkinter/__pycache__/ttk.cpython-38.pyc
python /usr/lib/python3.8/tkinter/colorchooser.py
python /usr/lib/python3.8/tkinter/commondialog.py
python /usr/lib/python3.8/tkinter/constants.py
python /usr/lib/python3.8/tkinter/dialog.py
python /usr/lib/python3.8/tkinter/dnd.py
python /usr/lib/python3.8/tkinter/filedialog.py
python /usr/lib/python3.8/tkinter/font.py
python /usr/lib/python3.8/tkinter/messagebox.py
python /usr/lib/python3.8/tkinter/scrolledtext.py
python /usr/lib/python3.8/tkinter/simpledialog.py
python /usr/lib/python3.8/tkinter/tix.py
python /usr/lib/python3.8/tkinter/ttk.py

It's likely that the API changed, maybe look at an updated usage tutorial.

Offline

#3 2020-11-03 10:16:32

dauriac
Member
Registered: 2019-01-29
Posts: 39

Re: Tkinter with python3 [SOLVED]

Apparently using

 import tkinter as Tkinter

works
sorry for a  post not useful

Offline

#4 2020-11-03 10:22:24

dauriac
Member
Registered: 2019-01-29
Posts: 39

Re: Tkinter with python3 [SOLVED]

V1del : thank you
by not working I meant that the import Tkinter  yields ModuleNotFoundError.
But import tkinter works. So apparently two modules exist one for 2, the other for 3.

Offline

#5 2020-11-03 10:24:43

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 18,212

Re: Tkinter with python3 [SOLVED]

Well yes, that's why they are different and technically incompatible  language versions.

Please mark as [SOLVED] by editing the title in your first post.

Offline

Board footer

Powered by FluxBB