[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>&nbsp; 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>&nbsp;</DIV>
<DIV>********************************************************</DIV>
<DIV>self.canvas.tag_bind('movex1',"&lt;Enter&gt;",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lambda type=1, xy=1:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.ChangeCursor(type,xy))</DIV>
<DIV><BR>&nbsp;&nbsp;self.canvas.tag_bind('movey1',"&lt;Enter&gt;",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lambda&nbsp; event,type=1, xy=2:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.ChangeCursor(type,xy))</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;def ChangeCursor(self,event,type,xy):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if type == 1:&nbsp;&nbsp;&nbsp;&nbsp;#Mouse enter event<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if xy == 1:&nbsp; #X1/X2 position<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;self.canvas.config(cursor="sb_v_double_arrow")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  if xy == 2: #Y1/Y2 position<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; self.canvas.config(cursor="sb_h_double_arrow")</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</DIV>
<DIV>************************************************************************</DIV>
<DIV>&nbsp; When i ran my program i got the following error:</DIV>
<DIV>&nbsp;</DIV>
<DIV>TypeError: ChangeCursor() takes exactly 4 arguments (3 given).</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; Where the problem exist and how can i pass user define variables to ChangeCursor routine?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thanx.</DIV>
<DIV>&nbsp;</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--