I am trying to remove the default "box like" icon from the tkinter OptionMenu and replace it with my own image file. below is the code I have to date. It is working but I had to add the last line to get it to display the arrow image and for the OptionMenu to function. However, the arrow image is always imedately after the text rather than at the far right of the OptionMenu and sticky does not seam to be aplying hence the width=140. I am working in Python 2.6.
Any sugegestions for moving the image to the right?
...
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
...
You can use the ttk.Combobox
widget instead:
om = Combobox(root, values=*myOptList)
om.set(myVar)
om.grid(sticky=W + E, padx=5, pady=5)
om.config(compound='right', width=140)