takes no arguments (1 given)

M

Mike

In the following Display inherits from the Tkinter class Canvas:

import sys
from Tkinter import *
class Display(Canvas) :
....
def fill_canvas() :
slop=self.slop
set_sr(int(self.cget('width'))+slop,
int(self.cget('height'))+slop)
self.refresh()
....

disp=Display(fred, None)
disp.pack()
def stupid(unused) : disp.fill_canvas()
disp.bind("<Configure>", stupid)
mainloop()

From the above I get:
Exception in Tkinter callback
....
File Ca_canvas.py, line 173, in stupid
def stupid(unused) : disp.fill_canvas()
TypeError: fill_canvas() takes no arguments (1 given)


What is going on?
I tried to do something similar with lambda
and got the same result.
 
T

Tommy Grav

In the following Display inherits from the Tkinter class Canvas:

import sys
from Tkinter import *
class Display(Canvas) :
...
def fill_canvas() : def fill_canvas(self):
slop=self.slop
set_sr(int(self.cget('width'))+slop,
int(self.cget('height'))+slop)
self.refresh()
...

disp=Display(fred, None)
disp.pack()
def stupid(unused) : disp.fill_canvas()

Exception in Tkinter callback
...
File Ca_canvas.py, line 173, in stupid
def stupid(unused) : disp.fill_canvas()
TypeError: fill_canvas() takes no arguments (1 given)


What is going on?
I tried to do something similar with lambda
and got the same result.

The class method needs a self argument so that
disp.fill_canvas() can parse the class instance disp
to the method.

Cheers
TG
 
B

Bjoern Schliessmann

Tommy said:
The class method needs a self argument so that
disp.fill_canvas() can parse the class instance disp
to the method.

It's an instance method, no class method.

Regards,


Björn
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top