How do you import Tkinter in python?


#1

I am trying to learn python, and I took the fallowing peace of code from the internet:

import Tkinter

class simpleapp_tk(Tkinter.Tk):
def init(self,parent):
Tkinter.Tk.init(self,parent)
self.parent = parent
self.initialize()

def initialize(self):
    self.grid()

    self.entry = Tkinter.Entry(self)
    self.entry.grid(column=0,row=0,sticky='EW')

    button = Tkinter.Button(self,text=u"Click me !")
    button.grid(column=1,row=0)

if name == “main”:
app = simpleapp_tk(None)
app.title(‘my application’)
app.mainloop()

But it keeps giving me the same error message that says;
Traceback (most recent call last):
File “/home/ubuntu/workspace/README.md”, line 1, in
import Tkinter
ImportError: No module named ‘Tkinter’

Here is a picture of my screen:

Can anyone please help?


#2

Please see my response to an identical problem:

If this isn’t the problem, please respond and I’ll try to see if I can figure it out.


#3

I’m having this same issue. When I try to install tkinter with pip in Python 2 or 3, I get the error “Could not find a version that satisfies the requirement tkinter”.

dev:~/environment $ python -m tkinter
/usr/bin/python27: No module named tkinter