我在OptionMenu中加载了大量环境列表。当您打开它时,如果打开的菜单到达屏幕外,一旦松开鼠标按钮,它将立即关闭。有什么办法解决这个问题吗?(例如,使其更小、可滚动或停用所述功能)我在Linux20.04上测试了这一点,以防它在windows上有所不同。或者有人可以提到一个没有这个问题的下拉菜单
#!/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()
所以你可以自己尝试一下(只需确保它确实会伸出你的屏幕)
这里有一段视频:https://imgur.com/5Suqtiq
目前没有回答
相关问题 更多 >
编程相关推荐