Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8310371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:26:11+00:00 2026-06-08T19:26:11+00:00

In the code below I need to return all values returned (but for each

  • 0

In the code below I need to return all values returned (but for each row separately) but I have tried lambda and failed and I’m not getting anywhere AGAIN.

I also have the callback definition where it previously worked and when I click in a box, it deletes the grey writing so I can continue to input in black.

If possible I would like to add the value return for the entry box at the end of my callback function rather than keeping ‘numberwritten’ and ‘callback’..Is this possible?

The number of boxes added is equal to self.number_boxes and can be from 1 to n.

Thank you.

UPDATED CODE:

    self.numbers = [StringVar() for i in xrange(self.number_boxes) ] 

    for i in xrange(self.number_boxes):
          row = (row_number +add)
          column = self.column +i
          key = "%d/%d" % (row,column)
          self.clicked = ([False] * self.number_boxes)
          self.choice_title = Label(self.frame_table, bg=self.mycolour, borderwidth=0, width=10) 
          self.choice_title.grid(row=1, column=self.column, columnspan=self.number_boxes, sticky="nsew", padx=1, pady=1) 
          self.choice_titles.append(self.choice_title)
          self.box[key] = Entry(self.frame_table,bg='white',borderwidth=0, width=10, justify="center", fg='grey')
          self.box[key].grid(row=row_number+add,column=self.column+i, sticky='nsew', padx=1, pady=1) 
          self.box[key].insert(0, "Value %g" % float(i+1))
          self.box[key].bind("<Button-1>", lambda event, key=key, index=i : self.callback(event, key, index))
          self.boxes.append(self.box[key])


def callback(self, event, key, index):

    for not self.clicked[index]:
         self.box[key].delete(0, END)
         self.box[key].config(fg='black')
         self.clicked[index] = True

         print self.box[key].get()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:26:13+00:00Added an answer on June 8, 2026 at 7:26 pm

    You have at least a couple of choices. For one, you can store store the entry widgets in a dict or list of lists, then pass the index into the callback. For example:

    self.box = {}
    for i in xrange(self.number_boxes):
        row = row_number+add
        column = self.column+i
        key = "%d/%d" % (row,column)
        ...
        self.box[key] = Entry(...)
        self.box[key].bind("<Button-1>", lambda event, key=key: self.callback(event, key))
    

    The important thing is to not just pick a method somebody gives you on the internet, but to understand the problem and the tools you have to solve it. If you take the time to learn how lambda works (or functools.partial) and have a basic understanding of fundamental data structures like lists and dicts, problems like this will cease to be stumbling blocks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code below. I need to use a class id instead of
Please i need help, this code below works fine on my localhost, php5.3+ but
The code shows below what i have done till now. Now what i need
I need to convert a sql statement to a linq query. The code below
Am not that skilled at Excel/VBA and need some help. The code below (in
In the code shown below, I need to manipulate the time var in python
In the code given below, I need to position the userid box in the
In the code snippet below, from my jQuery setup, I need to check if
I need to fix a issue for xss vulnerability. the code segment is below.
I am new to linq. My code is as below . I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.