I am asking as lately while doing python GUI programing I installed tkinter by doing
apt-get install python3-tk
everything went well and when I opened python3 console while I was in the following directory
But I moved to an other folder called "tkinter" in "python-gui" folder and tried to compile the following code
import tkinter as tk class Application(tk.Frame): def __init__(self, master=None): tk.Frame.__init__(self, master) self.pack() self.createWidgets() def createWidgets(self): self.hi_there = tk.Button(self) self.hi_there["text"] = "Hello World\n(click me)" self.hi_there["command"] = self.say_hi self.hi_there.pack(side="top") self.QUIT = tk.Button(self, text="QUIT", fg="red", command=root.destroy) self.QUIT.pack(side="bottom") def say_hi(self): print("hi there, everyone!") root = tk.Tk() app = Application(master=root) app.mainloop()
and surprisingly I get this error
Traceback (most recent call last): File "tkinter.py", line 1, in <module> import tkinter as tk File "/root/python_gui/tkinter/tkinter.py", line 3, in <module> class Application(tk.Frame): AttributeError: 'module' object has no attribute 'Frame'
so I entered python3 console from that path and tried importing tkinter inside the console but again got the same error, but when I try compiling the same code under "python-gui" folder directly it imports and compiles properly, and also when I am in "~/python-gui/tkinter/" folder I tried
tkinter didnt import again but I come out and try again it does, why isn't python module not working in the "/tkinter/" folder ? and how do I fix this ?
os info : Linux root 4.0.0-kali1-amd64 #1 SMP Debian 4.0.4-1+kali2 (2015-06-03) x86_64 GNU/Linux
python : python 3.4.2