471,330 Members | 1,169 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

takes no arguments (1 given)

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.
Dec 3 '07 #1
2 16399

On Dec 3, 2007, at 2:10 PM, Mike wrote:
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()
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.
The class method needs a self argument so that
disp.fill_canvas() can parse the class instance disp
to the method.

Cheers
TG

Dec 3 '07 #2
Oops. I just forgot self.
Dec 3 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by SK | last post: by
26 posts views Thread by Martin Jørgensen | last post: by
1 post views Thread by Jean Paul Mertens | last post: by
1 post views Thread by Tom Harris | last post: by
8 posts views Thread by The87Boy | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.