Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tkinter drop down list of check-boxes/combo-boxes

I am attempting to create a post-processing data application in Python, and I am designing the GUI for this using Tkinter.

I do not know if Tkinter supports a drop down list composed of check boxes, of which you can then select multiple boxes from. The picture below reflects what I am attempting to describe:

enter image description here

Is this possible?

like image 575
reyyez Avatar asked Nov 18 '15 13:11

reyyez


2 Answers

I became a bit obsessed with this problem and subsequently spent some time trying to solve it. I think I came up with a pretty decent solution -- or at least the beginnings of a pretty decent solution. If you do use this code and run into any bugs or issues, please do let me know by posting an "Issue" on the GitHub page.

https://github.com/hatfullr/ChecklistCombobox

like image 147
boof Avatar answered Oct 22 '22 12:10

boof


Its not exactly what you wanted, but hope it helps.

from Tkinter import *

top = Tk()

mb=  Menubutton ( top, text="CheckComboBox", relief=RAISED )
mb.grid()
mb.menu  =  Menu ( mb, tearoff = 0 )
mb["menu"]  =  mb.menu

Item0 = IntVar()
Item1 = IntVar()
Item2 = IntVar()

mb.menu.add_checkbutton ( label="Item0", variable=Item0)
mb.menu.add_checkbutton ( label="Item1", variable=Item1)
mb.menu.add_checkbutton ( label="Item2", variable=Item2)


'''This part is only for testing
def Item_test():
    if Item0.get() == True:
        print "Item0 True"
    elif Item0.get() == False:
        print "Item0 False"
    else:
        print Item0.get()
    if Item1.get() == True:
        print "Item1 True"
    elif Item1.get() == False:
        print "Item1 False"
    else:
        print Item1.get()
    if Item2.get() == True:
        print "Item2 True"
    elif Item2.get() == False:
        print "Item2 False"
    else:
        print Item2.get()

button1 = Button(top, text="Item True/False Test", command = Item_test)
button1.pack()
''' 

mb.pack()
top.mainloop()
like image 5
Zero Avatar answered Oct 22 '22 12:10

Zero