2

I started to learn GUI developement using the Tkinter python library but I faced a problem with the PyCharm IDE community edition 4.5.2

My problem is: when I write the code below in the IDLE, it works fine!!! but when I write it using the the PyCharm IDE, this error message appears: AttributeError: 'module' object has no attribute 'Tk' Please help me, I really need help and thank you a lot

My code:

import Tkinter

app = Tkinter.Tk()
app.title("hello world")
app.minsize(300, 300)
helloLabel = Tkinter.Label(app, text="hello GUI")
helloLabel.pack()

app.mainloop()

Note: I'm using Python 2.7.6, OS: Ubuntu 14.04 LTS

2
  • Did you name your file Tkinter.py? Jul 8, 2015 at 22:31
  • yes sir it's Tkinter.py Jul 8, 2015 at 23:24

1 Answer 1

12

The problem is that you named your file Tkinter.py. When you do the import, python sees the file and tries to import it instead of the Tkinter library.

Rename your file, and be sure to remove Tkinter.pyc if it exists.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.