How to add custom icon to actions via python scripting?

some tips:
plugin developer plugin is good for hunting down names for krita i con set.
QToolbutton QPushButton have setIcon method.

nameofbutton.setIcon(icon)

icon is an object of type QIcon i think… so you can get one of the set krita icon by

Krita.instance().icon(‘name of krita icon’)
ie . Krita.instance().icon(‘view-list-text’)

so something like
nameofbutton.setIcon( Krita.instance().icon(‘view-list-text’) )

refer to @KnowZero example.

Now for custom icons - thats a bit more work. I only have experience in making sets from svg.
for that I followed Krita style of svg as much as possible.

Which is create 22x22 px svg icon set and save them in a folder inside your plugin. [one for light background one for dark]

Also you need to create a custom class, to pick up the image, this include a dictionary of name a method that will make the svg become QIcon. It helps if you pattern it to krita with the icon method returning an icon object.

converting an svg to QIcon:
QIcon icon1 = QIcon()
icon1.addFile(path_to_icon_file, size_of_icon)

if you are interested with custom icons, I can offer my plugin CompactBrushToggler as reference. I have a class name CBT_Icon that can be use to pattern your code.