Python Forum
Parameters for function in bind()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parameters for function in bind()
#1
Hello,

self.canvas.bind("<B1-Motion>", self.move

I would like to call this function (self.move) also with some parameters, but I'm not sure, how to do it. This bind is inside a for loop, with variable 'i', and I want to call self.move with different values 'i'. Is there any way how to add a parameter to function in binding?
Reply
#2
use partial, although I am just guessing as you didn't post enough code
from functools import partial
## rest of code
self.canvas.bind("<B1-Motion>", partial(self.move, i)) 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to compare two parameters in a function that has *args? Milan 4 1,183 Mar-26-2023, 07:43 PM
Last Post: Milan
  function accepts infinite parameters and returns a graph with those values edencthompson 0 812 Jun-10-2022, 03:42 PM
Last Post: edencthompson
  How to bind a midi signal to tkinter? philipbergwerf 1 1,567 Feb-09-2022, 05:17 PM
Last Post: Gribouillis
  How can I write a function with three parameters? MehmetAliKarabulut 1 2,376 Mar-04-2021, 10:47 PM
Last Post: Larz60+
  Parameters aren't seen inside function Sancho_Pansa 8 2,815 Oct-27-2020, 07:52 AM
Last Post: Sancho_Pansa
  RuntimeError: Optimal parameters not found: Number of calls to function has reached m bntayfur 0 6,073 Aug-05-2020, 04:41 PM
Last Post: bntayfur
  Function parameters and values as string infobound 1 1,728 Jul-24-2020, 04:28 AM
Last Post: scidam
  function 2 inside function 1 parameters SheeppOSU 4 2,794 Apr-20-2019, 09:34 PM
Last Post: snippsat
  Parameters type in a function girbinho 2 2,695 Oct-09-2018, 10:36 PM
Last Post: micseydel
  Function parameters grkiran2011 2 2,668 Feb-10-2018, 01:18 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020