Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Layer opacity shortcut
#2
Have a look at this:
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.
Reply


Messages In This Thread
Layer opacity shortcut - by DaveMac - 03-16-2018, 08:20 AM
RE: Layer opacity shortcut - by Kevin - 03-16-2018, 09:42 AM
RE: Layer opacity shortcut - by Ofnuts - 03-16-2018, 10:07 AM
RE: Layer opacity shortcut - by DaveMac - 03-16-2018, 08:28 PM
RE: Layer opacity shortcut - by Ofnuts - 03-16-2018, 11:51 PM
RE: Layer opacity shortcut - by DaveMac - 03-17-2018, 04:16 PM
RE: Layer opacity shortcut - by Ofnuts - 03-17-2018, 05:56 PM
RE: Layer opacity shortcut - by DaveMac - 04-10-2018, 02:14 PM

Forum Jump: