我想要替换tkinter OptionMenu默认的“盒状图标”,使用自己的图片文件。以下是我目前为止拥有的代码。它正在工作,但是我必须添加最后一行才能显示箭头图像并使OptionMenu正常工作。然而,箭头图像总是出现在文本之后,而不是OptionMenu的极右边,并且粘性似乎没有应用,因此width = 140。我正在Python 2.6中工作。您有移动图像到右边的任何建议吗?
...
arrow = PhotoImage(file='arrow.gif')
om = OptionMenu(root,myVar,*myOptList)
om.grid(sticky=W+E,padx=5,pady=5)
om.config(indictoron=0,compound='right',image=arrow,width=140)
om.image=arrow
...
ttk.OptionMenu
? - martineauOptionMenu
不够了解,无法推荐。 - Peter WoodOptionMenu
而不是Combobox
。搜索一下你就会发现。它们还有文档字符串。 - martineauttk.OptionMenu
文档 链接。 - martineau