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

  • Home
  • SEARCH
  • 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 8120543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:11:13+00:00 2026-06-06T05:11:13+00:00

I have two OptionMenu widgets in the simple pieces of code shown below: variable

  • 0

I have two OptionMenu widgets in the simple pieces of code shown below:

    variable = StringVar(win1)                               
    variable.set(number(number2))
    type = OptionMenu(win1, variable, "None", "Clear", "Dark", "Heavy", )
    type.grid(row=i, column=3, sticky="nsew", padx=1, pady=1)


    variableunit = StringVar(win1)
    variableunit.set(unit)
    unit = OptionMenu(win1, variableunit, "colour", "shade")
    unit.grid(row=i, column=5, sticky="nsew", padx=1, pady=1)

I have tried traces with a callback function and so far hasn’t worked. I would like to link when “Heavy” is chosen in the first menu, the second menu is always “colour”. For the rest of the choices, the second menu must always be a default of “shade” but can be changed.

I would be grateful is anyone could help me. I’ve already looked at the effbot site with variables and traces but am still stuck.

  • 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-06T05:11:14+00:00Added an answer on June 6, 2026 at 5:11 am

    It’s not exactly clear what you want, but I think this should do it.

    When “Heavy” is selected in the first menu, “colour” is selected in the second one and that menu is disabled (can’t select anything else). When something else is selected in the first menu, the second one goes to “mm” and is enabled again.

    from Tkinter import *
    
    class app:
        def __init__(self, root):
            win1 = Frame(root)
            win1.grid(row=0,column=0)
    
            self.variable = StringVar(win1)                               
            self.variable.set(42)
            self.type = OptionMenu(win1, self.variable,
                              "None", "Clear", "Dark", "Heavy",
                              command = self.varMenu)
            self.type.grid(row=1, column=3, sticky="nsew", padx=1, pady=1)
    
    
            self.variableunit = StringVar(win1)
            self.variableunit.set('mm')
            self.unit = OptionMenu(win1,
                              self.variableunit, "mm", "colour", "shade")
            self.unit.grid(row=1, column=5, sticky="nsew", padx=1, pady=1)
    
        def varMenu(self, selection):
            if selection == "Heavy":
                self.variableunit.set("colour")
                self.unit.config(state = DISABLED)
            else:
                self.variableunit.set("mm")
                self.unit.config(state = NORMAL)
    
    root = Tk()
    a = app(root)
    root.mainloop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two different Classes: class X { public int TX1 { get; set;
I have two custom widgets (two classes based on QtGui.QWidget). In __init__ of QtGui.QMainWindow
I have two items in the Dropdown list and i have the code for
I have two pictures on top of each other: Here is the code: <div
Have two folders with approx. 150 java property files. In a shell script, how
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two tables users and work_orders. Now I need to get work_orders results
I have two classes which need to be in same xml file. The way
I have two tables. One is Employee_Mstr and other is EmployeeLeaveRequest_mstr . My data:
I have two XML files. The first XML has a bunch of nodes that

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.