I have managed to change the indicator within the optionmenu box through using indicatoron=0, compound=RIGHT, image=dropImg, width=120 but I am now trying to change the arrow to point up when the box is clicked and the list of elements are shown.
For instance:
I tried activeindicatoron = 0 but this doesn't work. Does anyone have any ideas on whether this is possible in tkinter?
Thanks, Jacob
Yes it is possible. For instance, you can
Use the
postcommandoption of the Optionmenu's menu to change the image on the button to an arrow pointing up.Use a binding to the
<Unmap>event of the Optionmenu's menu to revert to the arrow pointing down when the menu disappears.Here is an example:
TTK version
It is also possible to achieve this when using a
ttk.OptionMenuand I think it look nicer because the arrow really replaces the indicator instead of being in the place of the image. This can be done by modifying the layout of theTMenubuttonstyle:Create 'up' and 'down' elements from the images
Create 'up.TMenubutton' and 'down.TMenubutton' layouts from the 'TMenubutton' layout (obtain with
style.layout('TMenubutton')) by replacing 'Menubutton.indicator' by 'up' or 'down'.Use
postcommandand<Unmap>to change the style of the Menubutton.Here is the code: