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 8315643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:10:42+00:00 2026-06-08T21:10:42+00:00

The following code shows my two option menus and the callback function ‘VarMenu’. This

  • 0

The following code shows my two option menus and the callback function ‘VarMenu’. This all works all well and good except as I created several of the same option menus in the loop for each row. When only one of them is changed to ‘L’, I want only that corresponding row for the unit option menu to be changed to ‘N’ and not the every single one of them.

I don’t want to confuse things too much with lists or huge lines of code but if I created a list self.type = [] would that work?

Thank you in advance!

def VarMenu(self, selection):

    if selection == "L":
        self.variableunit.set("N")
        self.unit.config(state=DISABLED)
    else:
        self.variableunit.set("mm")
        self.unit.config(state=NORMAL)

def import_file(self): # Not complete code
    for row_number, row_data in enumerate(info):
        self.variable = StringVar(self.frame_table)                                
        self.variable.set(pre(code))
        self.type = OptionMenu(self.frame_table, self.variable, "None", "Clear", "F", "L", command=self.VarMenu)
        self.type.grid(row=row_number+i, column=3, sticky="nsew", padx=1, pady=1)

    # Unit drop down menu
        self.unit = OptionMenu(self.frame_table, self.variableunit, "mm", "N")
        self.unit.grid(row=row_number+i, column=5, sticky="nsew", padx=1, pady=1)
  • 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-08T21:10:44+00:00Added an answer on June 8, 2026 at 9:10 pm

    When you do this:

    for row_number, row_data in enumerate(info):
        self.variable = StringVar(...)
    

    … do you realize that you keep overwriting self.variable with the most recently created one? How do you expect it to somehow magically hold more than one variable?

    Instead, you simply need to pass the variable to the callback using lambda or functools.partial. For example:

    for row_number, row_data in enumerate(info):
        var = StringVar(...)
        self.type = OptionMenu(..., command=lambda new_value, variable=var: self.VarMenu(new_value, variable)
    

    Of course, you can pass in the row number or any other information you want in your callbacks.

    Note: the OptionMenu is designed such that when it calls your callback, it will always pass one argument that is the new value selected by the user. This argument will always be present. You can, however, add additional arguments as shown in my example.

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

Sidebar

Related Questions

The following code shows a bug I'm trying to fix. I have two ways
The following code, from the Google-Caja playground,shows two boxes. And once you drag on
The following code shows a button that allows you to select a file (should
The following code shows 1 view, 1 partial view, and 1 controller . The
The following code shows what I currently have. It is an adapter for circular
Currently, the following code shows a blank line if Address2 (which comes from the
Consider the following code which shows compile time error : #include <stdio.h> int main(int
The following code with alternating background I have shows up fine in Chrome and
In the following code every time button is clicked the alter shows the value
In the following code, the first log statement shows a decimal as expected, but

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.