1

I get this error from tkinter.Text():

>>> import tkinter
>>> tkinter.Text()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/tkinter/__init__.py", line 3095, in __init__
    Widget.__init__(self, master, 'text', cnf, kw)
  File "/usr/lib/python3.6/tkinter/__init__.py", line 2293, in __init__
    (widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: expected integer but got "sans"

or even tkinter._test() :

>>> tkinter._test()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/tkinter/__init__.py", line 3985, in _test
    label = Label(root, text=text)
  File "/usr/lib/python3.6/tkinter/__init__.py", line 2760, in __init__
    Widget.__init__(self, master, 'label', cnf, kw)
  File "/usr/lib/python3.6/tkinter/__init__.py", line 2293, in __init__
    (widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: expected integer but got "sans"

The message is pretty clear, but I don't know where to start.

EDIT : I got this error when I tried to use matplotlib.pyplot.plot(). But this worked (no error anymore) for matplotlib. I didn't find a similar way to deal with tkinter.

Thibaut
  • 41
  • 8

1 Answers1

0

I am not getting any kind of error with the same code, so I can't debug it. So, I think you should try the following:

from tkinter import *
root=Tk()
log = Text(root, state='disabled', width=80, height=24, wrap='none')
log.grid()
root.mainloop()

If it doesn't work and other widgets like, buttons and entries don't work then there is something wrong with the tkinter that you have installed. So, try to unistall and then, reinstall tkinter:

sudo apt-get remove python3-tk
sudo apt-get install python3-tk

If the above gives an error,use this link to check for your your version of linux, how to do it (refer to the comments also) : Install tkinter for Python

Try it and let me know if that helps.

Eshita Shukla
  • 791
  • 1
  • 8
  • 30
  • I get the same error message, as soon as I call Text(), even with no argument. – Thibaut Jun 26 '18 at 12:02
  • The widgets that do not send this error are Canvas, Frame, OptionMenu, PanedWindow, Scrollbar, Toplevel (the ones that don't need text I suppose). – Thibaut Jun 28 '18 at 17:28