Tkinter on Ubuntu 14.04 seems not to work

Posted by empedokles on Ask Ubuntu See other posts from Ask Ubuntu or by empedokles
Published on 2014-08-20T20:25:22Z Indexed on 2014/08/21 22:27 UTC
Read the original article Hit count: 443

Filed under:
|
|
|

I receive following Traceback:

Traceback (most recent call last):
  File "tkinter_basic_frame.py", line 4, in <module>
    from Tkinter import Tk, Frame, BOTH
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in 
    raise ImportError, str(msg) + ', please install the python-tk package'
ImportError: No module named _tkinter, please install the python-tk package

This is the demoscript I'm trying to run:

#!/usr/bin/python
# -*- coding: utf-8 -*-

from Tkinter import Tk, Frame, BOTH


class Example(Frame):

    def __init__(self, parent):
        Frame.__init__(self, parent, background="white")   

        self.parent = parent

        self.initUI()

    def initUI(self):

        self.parent.title("Simple")
        self.pack(fill=BOTH, expand=1)


def main():

    root = Tk()
    root.geometry("250x150+300+300")
    app = Example(root)
    root.mainloop()  


if __name__ == '__main__':
    main()  

From my knowledge Tkinter should be included in Python 2.7. Why do I receive the traceback? Doesn't ubuntu contain the standard-python-distribution?

This is solved. I had to install it manually in synaptic (got the hint in the meantime from another forum), see here:

enter image description here

Wikipedia says: "Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit1 and is Python's de facto standard GUI,2 and is included with the standard Windows and Mac OS X install of Python." - Not good, that it isn't included in Ubuntu as well.

Tkinter on Wikipedia

© Ask Ubuntu or respective owner

Related posts about 14.04

Related posts about python