Tkinter Problem?

Peter Otten __peter__ at web.de
Tue Nov 20 10:10:53 CET 2007


Marc 'BlackJack' Rintsch wrote:

> On Mon, 19 Nov 2007 18:13:03 -0800, Davy wrote:
> 
>> ##----------------------
>> from Tkinter import *
>> 
>> class MyApp:
>>     def __init__(self,parent):
>>         self.myContainer1 = Frame(parent)
>>         self.myContainer1.pack()
>>         self.canv = Canvas(relief=SUNKEN)
>>         self.canv.config(width = 300,height=300)
>>         self.canv.pack()
>>         self.canv.create_rectangle(100,100,150,150,tags="rect")
>>         self.canv.bind('<Up>',self._onUpKey)
>>         self.canv.bind('<Return>', self._onReturnKey)
>>     def _onUpKey(self,event):
>>         self.canv.move(tagOrId,xAmount=0,yAmount=10)
> 
> Where's `tagOrId` coming from?  That's a `NameError` here.

Also, the arguments of Canvas.move() are positional.

self.canv.move("rect", 0, 10)

should work though the direction of the move might surprise you.

Peter



More information about the Python-list mailing list