I have a perfectly functional TkInter right click context menu, with 4 items and 1 separator, however I am trying to find out how to be able to display an icon with each item, I have managed to get the items to show as icons but this removes visibility of the actual text, which is not ideal. Does anyone know how to get the text to display to the right of the icon?
I will paste snippets of the code and the actual menu.
try:
def rClick_Copy(e, apnd=0):
e.widget.event_generate('<Control-c>')
def rClick_Cut(e):
e.widget.event_generate('<Control-x>')
def rClick_Paste(e):
e.widget.event_generate('<Control-v>')
def rClick_SelectA(e):
e.widget.select_range(0, 'end')
e.widget.icursor('end')
e.widget.focus()
nclst=[
('Cut', lambda e=e: rClick_Cut(e)),
('Copy', lambda e=e: rClick_Copy(e)),
('Paste', lambda e=e: rClick_Paste(e)),
('Seperator', ''),
('Select All', lambda e=e: rClick_SelectA(e)),
]
rmenu = Menu(None, tearoff=0, takefocus=0)
for (txt, cmd) in nclst:
if txt == 'Seperator':
rmenu.add_separator()
continue
rmenu.add_command(label=txt, command=cmd,) #image=self._img4 <add this in when using icons.
rmenu.tk_popup(e.x_root+40, e.y_root+10,entry="0")
except TclError:
print ' - rClick menu, something wrong'
pass
The Right Click Menu:
The Right Click Menu With Icons: