Reputation: 66
class Editor():
def __init__(self):
self=Tkinter.Tk()
EditedSongName=StringVar()
EditedArtistName=StringVar()
SongNameLabel = Label(self, text="Song Name:")
SongNameLabel.pack()
SongNameEntry = Entry( self,textvariable=EditedSongName)
SongNameEntry.pack()
ArtistNameLabel = Label(self, text="Artist Name:")
ArtistNameLabel.pack()
ArtistNameEntry = Entry( self,textvariable=EditedArtistName)
ArtistNameEntry.pack()
EditOkButton = Button( self, text="Ok", command=EditOk )
EditOkButton.pack(anchor=CENTER)
self.mainloop()
def EditOk(self):
print "RSAOJ"
Root.canvas.delete(SongName)
SongName=canvas.create_text(650,30,text = EditedSongName,fill = 'black',font=("Times New Roman",35) )
canvas.pack()
Root.canvas.delete(ArtistName)
ArtistName=canvas.create_text(650,90,text = EditedArtistName,fill = 'black',font=("Times New Roman",20) )
canvas.pack()
self.destroy()
No matter how i change the function, there is always an error. NameError: global name 'EditOk' is not defined What is that suppose to mean? I still can't get the concept of classes and selfs.
Upvotes: 0
Views: 544
Reputation: 6633
Try
EditOkButton = Button( self, text="Ok", command=self.EditOk )
Rather than
EditOkButton = Button( self, text="Ok", command=EditOk )
the method is only defined for a particular instance
Upvotes: 1