Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My first python plugin review
#14
elif(background_type == 1 or background_type == 2 or background_type == 3) better written as if background_type in [1,2,3]

elif(background_type == 4): # transparent background
# do nothing since resized canvas background is already transparent
pass


better written as
else: # transparent background case: do nothing since resized canvas background is already transparent
pass

(always better to have an explicit else to catch what we could have forgotten)

Instead of saving the color, you can bracket your code with gimp.context_push()/gimp.context_pop() (like the undo group), so that any context change you make for the script is reset when the script exits.

Blur radius can be a PF_SLIDER, easier for the user and since you add value boundaries you naturally limit the user to what Gimp's blur allows.

When you use pre-defined values as parameters, use their name, for instance pdb.gimp_image_merge_down(image, drawable, 1) is better written pdb.gimp_image_merge_down(image, drawable,CLIP_TO_IMAGE ) (note the "-/_" substitution).
Reply


Messages In This Thread
My first python plugin review - by origamifreak2 - 12-28-2024, 02:59 AM
RE: My first python plugin review - by Ofnuts - 12-28-2024, 09:08 AM
RE: My first python plugin review - by Ofnuts - 12-29-2024, 09:18 AM
RE: My first python plugin review - by gasMask - 12-29-2024, 12:22 AM
RE: My first python plugin review - by Ofnuts - 12-31-2024, 09:56 PM
RE: My first python plugin review - by Ofnuts - 01-01-2025, 09:26 AM
RE: My first python plugin review - by Ofnuts - 01-06-2025, 09:03 AM

Forum Jump: