0

I have find many questions like mine in site. But these answers can't help me, so I had to put a question again.

from tkinter import *
class Application(Frame):
    def __init__(self, master = None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()
    def createWidgets(slef):
        self.helloLabel = Label(self, text = 'Hello, world!')
        self.helloLabel.pack()
        self.quitButton = Button(self, text='Quit', command = self.quit)
        self.quitButton.pack()
app = Application()
app.master.title('Hello World')
app.mainloop()

my os is windows10 and python version is 3.4.3

3
  • Do you mean Frame is not defined? Commented Aug 26, 2015 at 10:06
  • Yes, I forgot to add the contents of the errorname 'Frame' is not defined Commented Aug 26, 2015 at 10:07
  • @SDilmac I had changed it but no effect Commented Aug 26, 2015 at 10:09

1 Answer 1

1

If the issue really is -

NameError: name 'Frame' is not defined

Then my guess is that you have a tkinter.py in your system that is masking the actual tkinter module from library. If this is the case, then rename that file, such that it does not mask the library module.


Also, for the code posted above you have another issue, which would be the following from self.createWidgets() method -

NameError: name 'self' is not defined

This is because you have misspelled self in your createWidgets method. It should be self not slef , but you are trying to use self itself there. Example -

def createWidgets(self):
Sign up to request clarification or add additional context in comments.

7 Comments

Are you sure the from tkinter import * line is really there?
Do you have a tkinter.py in your working directory? Is your file called tkinter.py ?
Instead of editing your unrelated wrong answer with guesses, it should be deleted and any question relating to the question should be added to the comments
Think you ! I knew what wrong with my code, I had a tkinter.py in my working directory
@PadraicCunningham No idea what you are talking about.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.