Quick Script for using Tkinter / tkinter for Python 2. & Python 3.**
I had a script which had different imports of Python 2.* Tkinter so browsing a but I see that the answer are all scattered. Here a small summary with a safe Script for using both Python versions.
try: # Python 2.7
import Tkinter as tk
import tkColorChooser as color
import tkCommonDialog as cdialog
import Tkconstants as const
import Tkdnd as dnd
import tkFileDialog as fdialog
import tkFont as font
import tkMessageBox as msgbox
import ScrolledText as stext
import tkSimpleDialog as sdialog
import Tix as tix
import ttk
except ImportError: # Python 3.*
import tkinter as tk
from tkinter import (
colorchooser as color,
commondialog as cdialog,
constants as const,
dialog,
dnd,
filedialog as fdialog,
font,
messagebox as msgbox,
scrolledtext as stext,
simpledialog as sdialog,
tix,
ttk
)
List of ModuleNotFoundError Errors (When Running Python 3.)
ModuleNotFoundError: No module named 'Tkinter'
ModuleNotFoundError: No module named 'tkMessageBox'
ModuleNotFoundError: No module named 'ScrolledText'
ModuleNotFoundError: No module named 'tkFileDialog'