Reputation: 2540
I write this simple code:
from tkinter import *
from tkinter import ttk
import tkinter.scrolledtext
root = Tk()
textPad = tkinter.scrolledtext(root)
textPad.pack()
root.mainloop()
But not run. output is:
Traceback (most recent call last):
File "E:/m/lale/test/test.py", line 6, in <module>
textPad = tkinter.scrolledtext(root)
TypeError: 'module' object is not callable
Upvotes: 5
Views: 9203
Reputation: 7646
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:
import Tkinter as tk
import tkMessageBox as tkm
import ScrolledText as tkst
from tkFileDialog import askopenfilename
except ImportError:
import tkinter as tk
import tkinter.messagebox as tkm
import tkinter.scrolledtext as tkst
from tkinter.filedialog import askopenfilename
ModuleNotFoundError: No module named 'Tkinter'
ModuleNotFoundError: No module named 'tkMessageBox'
ModuleNotFoundError: No module named 'ScrolledText'
ModuleNotFoundError: No module named 'tkFileDialog'
Upvotes: 0
Reputation: 1
In python 3.7 following worked for me,
import tkinter as tk
from tkinter import *
from tkinter import scrolledtext
txt = tk.scrolledtext.ScrolledText(window,width=40,height=10)
Upvotes: 0
Reputation: 19144
You are almost there. You need the ScrolledText class from the scrolledtext module. This works.
import tkinter as tk
from tkinter.scrolledtext import ScrolledText
root = tk.Tk()
textPad = ScrolledText(root)
textPad.pack()
root.mainloop()
Upvotes: 14