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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:43:10+00:00 2026-05-11T12:43:10+00:00

I have a list called ‘optionlist’ which may change length from day to day,

  • 0

I have a list called ‘optionlist’ which may change length from day to day, but I want a tkinter dropdown box to be able to select something from it.

Here’s an example of how to define a tkinter optionmenu:

opt1 = OptionMenu(root, var1, 'A', 'B', 'C')   

A, B, and C are the options you can select. The problem presented here is that while the OptionMenu is flexible and allows as many options as you want, you have to know exactly how many you want when you write the code. This isn’t a list or a tuple being passed.

I’m wondering if anyone knows any kung-fu for making this so I don’t have to do:

if len(optionlist) == 1:   opt1 = OptionMenu(root, var1, optionlist[0])   if len(optionlist) == 2:   opt1 = OptionMenu(root, var1, optionlist[0], optionlist[1])   etc, etc, etc 

I know you can define a list like this:

elements = [client.get('element') for client in clientlist] 

I’m hoping something similar can be done when passing to methods as well.

  • 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. 2026-05-11T12:43:10+00:00Added an answer on May 11, 2026 at 12:43 pm

    You want the * operator:

    opt1 = OptionMenu(root, var1, *optionlist) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a List called myData and I want to apply a particular method
I currently have a list called regkey and a string called line_to_delete, which I
I am working with Python plugins. I have my list called station_list ,to which
I have a list of type int, which contains ID's. For example it may
Good day. I have a dropdown list control called audioList. Whenever the page loads
I have an array list called str, i want to see how many elements
I have an array list called str, i want to see the elements inside
I have a list called com, which contains a bunch of integers. I need
So I have a list of lists called a, and I want to save
Suppose I have the list, which I have edited so it's not just called

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.