Reputation: 450
Is there a way to keep tkinter menu opened when clicking check button? In sample program when you click menu item the menu list disapear so you need to open menu again to click next item. So is there a way to keep menu oppended so multiple checkbox can be clicked?
from Tkinter import *
def click():
pass
root = Tk()
menu = Menu(root)
root.config(menu=menu)
choicesmenu = Menu(menu,tearoff=0)
menu.add_cascade(label="Choices", menu=choicesmenu)
choicesmenu.add_checkbutton(label="choice1", command=click)
choicesmenu.add_checkbutton(label="choice2", command=click)
choicesmenu.add_checkbutton(label="choice3", command=click)
choicesmenu.add_checkbutton(label="choice4", command=click)
choicesmenu.add_checkbutton(label="choice5", command=click)
choicesmenu.add_checkbutton(label="choice6", command=click)
choicesmenu.add_checkbutton(label="choice7", command=click)
mainloop()
Upvotes: 2
Views: 1676
Reputation: 22744
I advise you not to do what you are looking for because you are looking to disrupt the normal behavior of which the menu is intended to fulfill. Take a look to your browser's menu behavior and you will see it is not either behaving the way you want to do it. And luckily this is case, otherwise if your behavior is implemented, we will need to perform an additional click for anytime we pick something from the menu in order to hide this later one.
Adding to this, you are totally breaking the Principles of User Interface Design which I advice you to read.
You would have told me that your application needs that behavior anyway; for which thing my answer is, once again, against: if you need that behavior for your application then your design is wrong and I encourage to re-think your design twice before trying programming anything.
For your mere curiosity, however, you may take a look at: Keep a menu open in Tkinter
Upvotes: 1