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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:24:37+00:00 2026-05-25T13:24:37+00:00

my problem is the following: I have several files and I have made a

  • 0

my problem is the following: I have several files and I have made a drop down menu with the names,the next thing I need is an option menu which can be changed whenever a file name is selected to show some data from the specific file as option.To be clear,my question is only about how to make the option menu change when a choice from the drop down is selected.Thanks for any help.

  • 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-05-25T13:24:37+00:00Added an answer on May 25, 2026 at 1:24 pm

    The OptionMenu widget is nothing more than a convenience class that creates a menubutton that is associated with a menu. You can get at this menu via the "menu" attribute. The only trick is to knowing what the menu items should do, which is nothing more than setting the value of the associated variable.

    Here’s an example:

    import Tkinter as tk
    
    class SampleApp(tk.Tk):
        def __init__(self, *args, **kwargs):
            tk.Tk.__init__(self, *args, **kwargs)
            self.om_variable = tk.StringVar(self)
    
            b1 = tk.Button(self, text="Colors", width=8, command=self.use_colors)
            b2 = tk.Button(self, text="Sizes", width=8, command=self.use_sizes)
    
            self.om = tk.OptionMenu(self, self.om_variable, ())
            self.om.configure(width=20)
            self.use_colors()
    
            b1.pack(side="left")
            b2.pack(side="left")
            self.om.pack(side="left", fill="x", expand=True)
    
    
        def _reset_option_menu(self, options, index=None):
            '''reset the values in the option menu
    
            if index is given, set the value of the menu to
            the option at the given index
            '''
            menu = self.om["menu"]
            menu.delete(0, "end")
            for string in options:
                menu.add_command(label=string, 
                                 command=lambda value=string:
                                      self.om_variable.set(value))
            if index is not None:
                self.om_variable.set(options[index])
    
        def use_colors(self):
            '''Switch the option menu to display colors'''
            self._reset_option_menu(["red","orange","green","blue"], 0)
    
        def use_sizes(self):
            '''Switch the option menu to display sizes'''
            self._reset_option_menu(["x-small", "small", "medium", "large"], 0)
    
    if __name__ == "__main__":
        app = SampleApp()
        app.mainloop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem : several object files a1.o, a2.o, a3.o, ... an
I have the following HTML code (which is placed within several files), which inserts
I have a problem with the following situation: several commits are pushed to a
Hi i have following Problem. I write a Mediawiki Extension where i need some
if have the following problem: I have a List which i am going through
I have the following problem: We have a large product which is in master
I have the following problem: 1) There is some abstract class A with several
I have the following problem: My (C++-)project consists of several subprojects. In each, I
I have the following problem, which I think is related to caching but I
I have following problem: I have to make a ASP.NET Webapplication with a two-row

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.