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

Hamza Boughraira
  • 75
  • 2
  • 2
  • 7

1 Answers1

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.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685