0

So I am using xlrd module to read names of excel files of a workbook that user selects. Now this comes up in form of a list, which I am able to put in popup menu drop down(able to select on name at a time) now I want to

So far I am able to use the drop down menu of tkinter with dynamic input but able to select just one name at a time, now I want to select multiple items at a time by adding checkbox to the same. Can anyone help.. Here is sample code on which you anyone may please try adding checkbox and select multiple names at a time.

from tkinter import *

root = Tk()
a = [] #creates a list to store the job names in
var = StringVar() # creates a stringvar to store the value of options
for i  in range(20): # fills list with nonsense jobs for troubleshooting
    a.append("Job Name "+str(i))
var.set(a[0]) # sets the default option of options
options = OptionMenu(root, var, *a)   
# creates an option menu populated with every element of the list
button = Button(root, text="Ok", command=lambda:print(var.get()))
# prints the current value of options
options.pack()
button.pack()

The above code shows a drop down with single select able item, I just want multiple selection functionality enabled by adding checkbox in front of every option

4
  • Above drop down menu code is working properly if not the you may please check indentations Commented Aug 1, 2019 at 5:11
  • Need check button added to this drop down Commented Aug 1, 2019 at 5:11
  • 1
    I don't think you are looking into the right widget for this. Check the sample here for Menubutton instead. Commented Aug 1, 2019 at 6:19
  • Hi Henry I was finding solution since long it worked for me... Thanks,... Commented Aug 1, 2019 at 10:09

1 Answer 1

0

Use the MenuButton feature in tkinter. It has a method called Menu. To this method you could add as many check buttons as you want. This will support multiselect dropdown option. Give a variable name to each checkbutton and access its state through the get command.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Srikanth I already did it using list box, still thanks for taking out time will look forward to help you too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.