单击时 OptionMenu 不会显示第一个选项(Tkinter) [英] OptionMenu won't show the first option when clicked (Tkinter)

查看:30
本文介绍了单击时 OptionMenu 不会显示第一个选项(Tkinter)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的代码中添加了一个 OptionMenu 小部件,并分配了一个列表作为它的选项.事情是这样的:

I added a OptionMenu widget to my code, and assigned a list as it's options. This is how it is:

z = StringVar()   
z.set(userList[0])    
usersOption = OptionMenu(frame1, z, *userList)#, command=changeUser)
usersOption.pack(side=RIGHT, padx=3)

现在,我认为它会显示所述列表中的所有选项.如此:

Now, I reckon it would show all the options in said list. As so:

Option 1 \/ <-- the box with the selected option
Option 1 }\__the options that show on click
Option 2 }/

但它实际上只显示第二个选项,当我选择它时,基本上没有退路,如果我再次单击该框,它只会显示选项 2,即使使用 up 和向下键.我试图寻找解决方案,但我一无所获,所以我开始认为这是小部件的默认操作方式,但我在阅读的文档中没有找到任何可以告诉我如何解决它的方法.
PS:我使用的是 Python 3.3

but it actually only shows the second option, and when I choose it there is, basically, no way back, if I click the box again it keeps only showing option 2 and I can't change it even with the up and down keys. I tried looking for solutions, but I got nowhere, so I'm starting to think it is the default operating way of the widget, but I found nothing to show me how to solve it in the documentation I read.
P.S.: I'm using Python 3.3

推荐答案

Late answer..

Late answer..

随便用

self.option = OptionMenu(PARENT, VALUE TO BE CHANGED, "DEFAULT TEXT", *OPTIONS_ARRAY/LIST)

非常适合我.

这篇关于单击时 OptionMenu 不会显示第一个选项(Tkinter)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆