[Tutor] Passing user defined variables to mouseclick/enter/leave events
Python-lover
hemanexp@yahoo.com
Tue May 27 05:46:03 2003
--0-2029238476-1054028719=:33916
Content-Type: text/plain; charset=us-ascii
hi, I am using python and tkinter. Is it possible to pass user defined variables to and event that bind to mouse enter ("Enter" ) event. I want to pass some data to the event which is bound to "Enter" event. The coding is given below: ********************************************************self.canvas.tag_bind('movex1',"<Enter>",
lambda type=1, xy=1:
self.ChangeCursor(type,xy))
self.canvas.tag_bind('movey1',"<Enter>",
lambda event,type=1, xy=2:
self.ChangeCursor(type,xy)) def ChangeCursor(self,event,type,xy):
if type == 1: #Mouse enter event
if xy == 1: #X1/X2 position
self.canvas.config(cursor="sb_v_double_arrow")
if xy == 2: #Y1/Y2 position
self.canvas.config(cursor="sb_h_double_arrow") ************************************************************************ When i ran my program i got the following error: TypeError: ChangeCursor() takes exactly 4 arguments (3 given). Where the problem exist and how can i pass user define variables to ChangeCursor routine? Thanx.
---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
--0-2029238476-1054028719=:33916
Content-Type: text/html; charset=us-ascii
<DIV>hi,</DIV>
<DIV> I am using python and tkinter. Is it possible to pass user defined variables to and event that bind to mouse enter ("Enter" ) event. I want to pass some data to the event which is bound to "Enter" event. The coding is given below:</DIV>
<DIV> </DIV>
<DIV>********************************************************</DIV>
<DIV>self.canvas.tag_bind('movex1',"<Enter>",<BR> lambda type=1, xy=1:<BR> self.ChangeCursor(type,xy))</DIV>
<DIV><BR> self.canvas.tag_bind('movey1',"<Enter>",<BR> lambda event,type=1, xy=2:<BR> self.ChangeCursor(type,xy))</DIV>
<DIV> </DIV>
<DIV> def ChangeCursor(self,event,type,xy):<BR> if type == 1: #Mouse enter event<BR> if xy == 1: #X1/X2 position<BR> self.canvas.config(cursor="sb_v_double_arrow")<BR> if xy == 2: #Y1/Y2 position<BR> self.canvas.config(cursor="sb_h_double_arrow")</DIV>
<DIV> </DIV>
<DIV>************************************************************************</DIV>
<DIV> When i ran my program i got the following error:</DIV>
<DIV> </DIV>
<DIV>TypeError: ChangeCursor() takes exactly 4 arguments (3 given).</DIV>
<DIV> </DIV>
<DIV> Where the problem exist and how can i pass user define variables to ChangeCursor routine?</DIV>
<DIV> </DIV>
<DIV>Thanx.</DIV>
<DIV> </DIV><p><hr SIZE=1>
Do you Yahoo!?<br>
<a href="http://us.rd.yahoo.com/search/mailsig/*http://search.yahoo.com">The New Yahoo! Search</a> - Faster. Easier. Bingo.
--0-2029238476-1054028719=:33916--