0

I have an OptionMenu widget what I added some checkbuttons. It keeps closing when an item is check and I want it to stop doing this here's the code

drop1=OptionMenu(frame2, variable=clicked1,value="Options :")
other_variables={}
for o in other:
drop1['menu'].addcheckbutton(label=o,onvalue=1,offvalue=2,variable=var4, command=checkedOther)

Other is a list containing the items that need to be selected

1 Answers1

1

You can't stop the menu from closing, but you can show it back inside checkedOther() function:

def checkedOther(*args):
    # show the popup menu
    x, y, h = drop1.winfo_rootx(), drop1.winfo_rooty(), drop1.winfo_height()
    drop1['menu'].post(x, y+h)
acw1668
  • 40,144
  • 5
  • 22
  • 34
  • the x,y,h variables mean what – Casper Josiah Aug 17 '20 at 14:06
  • `(x, y)` is the coordinates of the top-left corner of `drop1` in the root window and `h` is the height of `drop1`. So `(x, y+h)` is the coordinates of the bottom-left corner of `drop1`. – acw1668 Aug 17 '20 at 15:08
  • the checkedOther function in my program is used to store the selected options should I still put the program in it or create a new function to store it in – Casper Josiah Aug 17 '20 at 19:19
  • You can still do whatever you do after showing the menu inside the function. – acw1668 Aug 18 '20 at 00:22