(Linux) In the following program when the command python permissions.ph is issued I simply get another prompt, but when python3 permissions.py is issued I get the error below. Why does python2 see tkinter but python 3 doesn't?

garrett@bedroom ~/Projects/TestArea $ python permissions.py 
garrett@bedroom ~/Projects/TestArea $ python3 permissions.py 
Traceback (most recent call last):
  File "permissions.py", line 1, in <module>
    from Tkinter import *
ImportError: No module named 'Tkinter'
garrett@bedroom ~/Projects/TestArea $ 






from Tkinter import *
def fileopenbox(msg=None, title=None, default=None):
    root = Tk()
    root.withdraw()
    f = tkFileDialog.askopenfilename(parent=root,title=title, initialfile=default)
    if not f: return None
    return os.path.normpath(f)

Recommended Answers

All 4 Replies

But I set same error when I change the line from Tkinter import * to from tkinter import *

And change to the tkinter.filedialog?

try:
    # for Python2
    import Tkinter as tk
    import tkFileDialog as tkfd
except ImportError:
    # for Python3
    import tkinter as tk
    import tkinter.filedialog as tkfd
commented: good help +14
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.