'NoneType' object has no attribute 'bind'

A

Alex

hi there, I keep getting the message in the Topic field above.

Here's my code:

self.click2=Button(root,text="Click Me").grid(column=4,row=10)
self.click2.bind("<Button-1>",self.pop2pop)

def pop2pop(self,event):

print("Adsfadsf")
newpop=IntVar()
newpop=self.PopSize.get();


what am I doing wrong?

cheers,

Alex
 
P

Peter Otten

Alex said:
hi there, I keep getting the message in the Topic field above.

Here's my code:

self.click2=Button(root,text="Click Me").grid(column=4,row=10)

Replace the above line to

button = Button(root, text="Click Me")
print "Button() returns", button
grid = button.grid(column=4, row=10)
print ".grid() returns", grid
self.click2 = button

and be enlighted. Then remove the print statements.
self.click2.bind("<Button-1>",self.pop2pop)

def pop2pop(self,event):

print("Adsfadsf")
newpop=IntVar()
newpop=self.PopSize.get();


what am I doing wrong?

If one step doesn't work try to replace it with smaller steps and add print
statements to find the part that doesn't do what you expected.

Peter
 
A

Alex Willmer

hi there, I keep getting the message in the Topic field above.

Here's my code:

self.click2=Button(root,text="Click Me").grid(column=4,row=10)
self.click2.bind("<Button-1>",self.pop2pop)

From reading the Tkinter docs grid doesn't itself return a control. So
I think you want this:

self.click2 = Button(root, text="Click Me")
self.click2.grid(column=4, row=10)
self.click2.bind("<Button-1>", self.pop2pop)

However, that's totally untested so don't take it as gospel.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top