Have a look at this:
Most of it is just menu registration and comments.
I expanded on the specification and made it look up the current opacity. If it's currently 100, it sets it to 60, otherwise it sets it to 100.
Code:
#!/usr/bin/env python
# Author: Me
# Copyright 2018
# License: GPL v3
# GIMP plugin to do stuf for DaveMac
# For DaveMac:- https://www.gimp-forum.net/Thread-Layer-opacity-shortcut
import sys
sys.stderr = open("C:/tmp/gimp_python_errs.txt",'a')
sys.stdout=sys.stderr
from gimpfu import *
pdb = gimp.pdb
# this is the bit that does all the work
def dave_mac(image,drawable):
if (drawable.opacity == 100):
drawable.opacity = 60.0
else:
drawable.opacity = 100.0
# The End of the main routine
# menu registration
register(
"python-fu-dave_mac",
"DaveMac",
"Change Layer Opacity",
"DaveMac",
"gimp-forum.net",
"16.03.2018",
"Change Layer Opacity",
"*",
[
(PF_IMAGE, "image", "Input image", None),
(PF_DRAWABLE, "drawable", "Input drawable", None),
],
[],
dave_mac,
menu="<Image>/Layer/"
)
main()
Most of it is just menu registration and comments.
I expanded on the specification and made it look up the current opacity. If it's currently 100, it sets it to 60, otherwise it sets it to 100.