I have a large list of environments loaded into an OptionMenu. When you open it, it will immediately close once you let go of the mouse button if the opened menu reaches outside of the screen. Is there any way to deal with this? (for example making it smaller and scrollable or deactivating said function) I tested this on Linux20.04 in case it is different on windows. Or can someone mention a dropdown-menu that doesn't have that problem.
#!/usr/bin/env python3
from tkinter import *
class Dropdown:
def __init__(self,options, master):
self.variable = StringVar(master)
self.variable.set(options[0]) # default value
self.menue = OptionMenu(master, self.variable, *options)
self.menue.pack()
typ = [
"Giftpflanze",
"Übernatürliche Pflanze",
"Heilpflanze",
"Nutzpflanze",
"Wehrende Pflanze",
"physische Wirkung",
"psychische Wirkung"
]
# Rad Suchschwierigkeit
# Rad Bestimmschwierigkeit
master = Tk()
d1 = Dropdown(typ,master)
def ok():
print ("value is:" + d1.variable.get())
button = Button(master, text="OK", command=ok)
button.pack()
mainloop()
So you can try it out on your own (just make sure it actually would reach out of your screen).
Here is a video: https://i.stack.imgur.com/aandv.jpg