Tkinter event binding

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Albinoswordfish
    New Member
    • Nov 2008
    • 1

    Tkinter event binding

    Right now I'm having trouble event binding an array of canvases.

    You see I want to create an array of canvases binding with double click, these binds call a function that take in an argument.

    my code is similar as follows

    Code:
    for dir in listofdir:
      thumbnail = Canvas(Master)
      thumbnail.bind("<Double-Button-1>",lambda x=dir: changedir(x))
      thumbnail.pack()
    however python tells me that I'm trying to pass in an instance of an object rather than a string(the function changedir concates a string and the given argument)

    Can anybody tell me what I'm doing wrong?
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Please enclose your posted code in [CODE] [/CODE] tags (See How to Ask a Question).

    This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

    Please use [CODE] [/CODE] tags in future.

    MODERATOR

    Comment

    Working...