It is currently Sat Jun 29, 2024 11:28 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Unable to get simple python plugin to show up
PostPosted: Wed Sep 29, 2021 6:52 am  (#1) 
Offline
GimpChat Member

Joined: Oct 10, 2014
Posts: 36
Thank you in advance for anybody helping.

I am using GIMP 2.10.28 on Windows 7. I am following the youtube video at

https://www.youtube.com/watch?v=nmb-0KcgXzI&t=480s&ab_channel=JacksonBates

for developing a simple Python plugin. I am unable to get the simple plugin to show up. The sample exercise in the video is to add a "gimp-Hello-Warning" in the File menu. But no matter where I put the .py file, it doesn't show up. I've tried all of the places in the edit -> preference -> folder -> plugins and no luck.

C:\Users\####\AppData\Roaming\GIMP\2.10\plug-ins
E:\Program Files\GIMP 2\lib\gimp\2.0\plug-ins

I even tried:

C:\Users\####\AppData\Roaming\GIMP\2.10\scripts
E:\Program Files\GIMP 2\lib\gimp\2.0\scripts

Here's the no brainer program

#!/usr/bin/env python

# Tutorial available at: https://www.youtube.com/watch?v=nmb-0KcgXzI # Feedback welcome: jacksonbates@hotmail.com

from gimpfu import *

def Hello-Warning(image, drawable): # function code goes here...
pdb.gimp_message("Hello World!")

register(
"python-fu-Hello-Warning",
"This is a short message",
"This is a long message",
"Myname", "Myname", "2021",
"NAME FOR MENU",
"*", # type of image it works on (*, RGB, RGB*, RGBA, GRAY etc...) [
# basic parameters are: (UI_ELEMENT, "variable", "label", Default) (PF_IMAGE, "image", "takes current image", None), (PF_DRAWABLE, "drawable", "Input layer", None) # PF_SLIDER, SPINNER have an extra tuple (min, max, step) # PF_RADIO has an extra tuples within a tuple: # eg. (("radio_label", "radio_value), ...) for as many radio buttons # PF_OPTION has an extra tuple containing options in drop-down list # eg. ("opt1", "opt2", ...) for as many options # see ui_examples_1.py and ui_examples_2.py for live examples ],
[],
Hello-Warning, menu="/File") # second item is menu location

main()


Last edited by ecs1749 on Wed Sep 29, 2021 7:45 am, edited 1 time in total.

Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Unable to get simple python plugin to show up
PostPosted: Wed Sep 29, 2021 7:43 am  (#2) 
Offline
Global Moderator
User avatar

Joined: Apr 01, 2012
Posts: 7742
Location: On the other side of this screen
A python or python-fu goes in your plug ins folder NOT your scripts folder.

When you look at your folders in your C:\Users\####\AppData\Roaming\GIMP\2.10\
Look for the plug in folder

_________________


Top
 Post subject: Re: Unable to get simple python plugin to show up
PostPosted: Wed Sep 29, 2021 7:47 am  (#3) 
Offline
GimpChat Member

Joined: Oct 10, 2014
Posts: 36
sallyanne wrote:
A python or python-fu goes in your plug ins folder NOT your scripts folder.

When you look at your folders in your C:\Users\####\AppData\Roaming\GIMP\2.10\
Look for the plug in folder


Thanks but I did try the plug-ins folders before trying the scripts folder.


Top
 Post subject: Re: Unable to get simple python plugin to show up
PostPosted: Wed Sep 29, 2021 7:53 am  (#4) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4752
The way you posted it you destroyed all indentation.

Very often the plugin contains syntax errors. You can run it outside of Gimp to check for the worst (and most frequent) ones; such as indentation, and unbalanced quotes and parentheses.

See https://www.gimp-forum.net/Thread-Debug ... in-Windows

In your case there is at least "Hello-Warning" which isn't a valid function name in Python (the "-" is always seen as a minus sign). Try "hello_warning" (snake_case, python style) or "helloWarning" (camelCase). It could also further complain about the menu location (try "<Image>/File" instead).

_________________
Image


Top
 Post subject: Re: Unable to get simple python plugin to show up
PostPosted: Wed Sep 29, 2021 10:31 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Aug 08, 2016
Posts: 2058
Location: East Midlands of England
Hi - getting started can be so frustrating.
There are so many things that can go wrong - hyphens instead of underscores, not indenting or using tab instead of inserting spaces - to say nothing of miserable error reporting.

Don't give up!

Below is your code up and running. I have moved the menu location to the Filters menu and added a toggle option (which does nothing) so that the message will (should) show up in a message box rather than just appear briefly below the image which makes it easy to miss.

Select and copy the code below into your text editor (I use Notepad++). Check that the indentations are all the same (4 spaces) and save it as a python file.


#!/usr/bin/env python
#
# -------------------------------------------------------------------------------------
#



from gimpfu import *



def Hello_Warning(image, drawable, hello):
    pdb.gimp_message("Hello")


   
register(
    "python_fu_python_fu_Hello_Warning_Plug_in",
    "This is a short message",
    "This is a long message",
    "No Brainer",
    "Open source (BSD 3-clause license)",
    "2021",
    "<Image>/Filters/Hello Warning...",
    "*",
    [
    (PF_TOGGLE, "Hello_Yes_or_no", "Say hello:", 0),
    ],
    [],
    Hello_Warning)

main()

_________________
Image

"Let no one steal your dreams."
Paul Cookson


Latest plug-in update: Paragrapher v.1.4
Custom Font Links
Tools
Character Paths
White Bases


Top
 Post subject: Re: Unable to get simple python plugin to show up
PostPosted: Wed Sep 29, 2021 11:55 am  (#6) 
Offline
GimpChat Member

Joined: Oct 10, 2014
Posts: 36
Thanks, that helps.

Reminds me of my first meeting with Python. I attended a training class and within 2 minutes, I was ready to walk out the door. All those indentation to me was a formula for failure. You guys are joking, right? And it's case sensitive? What's this, a Linux thingy?

The instructor urge me to stay for a little longer. "It will get better, a lot better, I promise", he said.

I've never looked back. Goodbye C, C++, Fortran, Rexx, Perl, ... and a gazillion other languages I dabbled with.

Python rules!


Top
 Post subject: Re: Unable to get simple python plugin to show up
PostPosted: Wed Sep 29, 2021 12:28 pm  (#7) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
I don't have a lot of years with GIMP python and I have created a few plugins. The main trick is to put your mind into the learning process of python. Like it was state it by the excellent coders here;

From ofnuts - "Very often the plugin contains syntax errors. You can run it outside of Gimp to check for the worst (and most frequent) ones; such as indentation, and unbalanced quotes and parentheses."

From Skinnyhouse - "Hi - getting started can be so frustrating.
There are so many things that can go wrong - hyphens instead of underscores, not indenting or using tab instead of inserting spaces - to say nothing of miserable error reporting."

"Don't give up!"


I think it was well said; Don't give up!

_________________
https://www.deviantart.com/pocholo17
Image


Top
 Post subject: Re: Unable to get simple python plugin to show up
PostPosted: Wed Sep 29, 2021 2:23 pm  (#8) 
Offline
GimpChat Member

Joined: Oct 10, 2014
Posts: 36
Rock and roll! Works.

Thanks, everybody.


Top
 Post subject: Re: Unable to get simple python plugin to show up
PostPosted: Wed Sep 29, 2021 4:07 pm  (#9) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4752
Pocholo wrote:
The main trick is to put your mind into the learning process of python.


.. and programming. Knowing a language and knowing programming are distinct skills.

_________________
Image


Top
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Convert GIMP plugin from Python 2 to Python 3

4

No new posts Attachment(s) Macbook User and Python plugin

14

No new posts Get a mouse click or select a pixel in an image in a python plugin?

3

No new posts Please make a python plugin to combine my GEGL filters with GMIC

1

No new posts Difference between "Python-Fu" and "Python" plugin

6



* Login  



Powered by phpBB3 © phpBB Group