Post Reply 

Sample plugins not showing up at all.

Feb 25, 2014, 20:16
Post: #1
Sample plugins not showing up at all.
I've got some sample plugins installed to my directory for plugins (C:\Documents and Settings\Thomas Morse\.gimp-2.6\plug-ins), but they aren't showing and I've closed gimp and opened it to find that they still aren't there.

I'm trying to learn what I need to off python-fu to make a function to make directories since I can't directly do it through script-fu.

Sample plugins I'm trying to use:


[undefined=undefined]
#!/usr/bin/env python

'''
demonstrate GUI widgets for Gimp plugins in Python
2009 Lloyd Konneker

This is a template for registration-time specs for plugin parameters,
demonstrating how to program them and what they look like in the GUI.

Notes:
The types like PF_xxx are types for plugin parameter specs at registration time.
(They are constants defined in the PyGimp package.)
There are similar types named SF_xxx for Scheme and C language.
Some of the PF_XXX types map to PDB_XXX types defined by gimp sourcecode.
See gimpfu.py for the mapping.

The Python types of actual parameter values sent to the plugin are different, and a smaller set.
For example, PF_INT8 becomes a Python integer.

Some type checking is done by PyGimp.
For example, PyGimp throws an exception when a user enters a alphabetic in a PF_FLOAT.
Exception is thrown when the user chooses OK button of the dialog.

The GUI widgets displayed are done by PyGimp, calling other libraries. See .../python/gimpui.py.

GUI style guide:
Don't use the capitalization shown here for descriptions, just capitalize the first letter.
Do use the colon after the description.
Do use keyboard shortcuts (underbar).
Use the ellipsis ... after the menu item if plugin opens a dialog.

Some would advise to right justify the descriptions.
Its hard to do (with spaces) and probably doesn't internationalize.
'''


def plugin_main( timg, tdrawable, p0, p02, p03, p04, p1, p2, p3, p4, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, p27, p28):
''' The meat of your plugin.
'''
pass


try:
# succeeds if path includes gimpfu (ie invoked from Gimp app as a plugin)
from gimpfu import *

register(
"python_fu_demo_GUI",
"Demonstrate builtin plugin GUI widgets",
"Does nothing but display builtin plugin widgets.",
"Lloyd Konneker (bootch nc.rr.com)",
"Copyright 2010 Lloyd Konneker",
"2010",
"<Image>/Filters/_Demo GUI widgets...",
"", # image types: blank means don't care but no image param
[
# Plugin parameter tuples: (type, name, description, default, [extra])
# Note these determine both the type of the parameter and the GUI widget displayed.
# Note the underbar in the description tells what letter is the shortcut key.
#
# Editable text boxes
(PF_INT, "p0", "_INT:", 0), # PF_INT8, PF_INT16, PF_INT32 similar but no difference in Python.
(PF_FLOAT, "p02", "_FLOAT:", 3.141),
(PF_STRING, "p03", "_STRING:", "foo"), # alias PF_VALUE
(PF_TEXT, "p04", "TEXT:", "bar"),
# PF_VALUE
# Pick one from set of choices
(PF_OPTION,"p1", "OPTION:", 0, ["0th","1st","2nd"]), # initially 0th is choice
(PF_RADIO, "p16", "RADIO:", 0, (("0th", 1),("1st",0))), # note bool indicates initial setting of buttons
# PF_RADIO is usually called a radio button group.
# SLIDER, ADJUSTMENT types require the extra parameter of the form (min, max, step).
(PF_TOGGLE, "p2", "TOGGLE:", 1), # initially True, checked. Alias PF_BOOL
# PF_TOGGLE is usually called a checkbox.
(PF_SLIDER, "p3", "SLIDER:", 0, (0, 100, 10)),
(PF_SPINNER, "p4", "SPINNER:", 21, (1, 1000, 50)), # alias PF_ADJUSTMENT
# Pickers ie combo boxes ie choosers from lists of existing Gimp objects
(PF_COLOR, "p14", "_COLOR:", (100, 21, 40) ), # extra param is RGB triple
# PF_COLOUR is an alias by aussie PyGimp author lol
(PF_IMAGE, "p15", "IMAGE:", None), # should be type gimp.image, but None works
(PF_FONT, "p17", "FONT:", 0),
(PF_FILE, "p18", "FILE:", 0),
(PF_BRUSH, "p19", "BRUSH:", 0),
(PF_PATTERN, "p20", "PATTERN:", 0),
(PF_GRADIENT, "p21", "GRADIENT:", 0),
(PF_PALETTE, "p22", "PALETTE:", 0),
(PF_LAYER, "p23", "LAYER:", None),
(PF_CHANNEL, "p24", "CHANNEL:", None), # ??? Usually empty, I don't know why.
(PF_DRAWABLE, "p25", "DRAWABLE:", None),
# Mostly undocumented, but work
(PF_VECTORS, "p26", "VECTORS:", None),
(PF_FILENAME, "p27", "FILENAME:", 0),
(PF_DIRNAME, "p28", "DIRNAME:", 0)
# PF_REGION might work but probably of little use. See gimpfu.py.
],
[],
plugin_main
menu="<Image>/Filters")

# Optional registration parameters in PyGimp:
# menu="<Image>/Filters") # This is really the menupath, the menuitem is above and can include the path
# !!! But note no parameters are passed for certain menu paths.
# Certain menu path prefixes are mangled by PyGimp: <Image>/Languages means sibling to Script Fu and Python Fu items.
# domain=("gimp20-python", gimp.locale_directory) # internationalization
#)

print "Calling main"
main()

except:
'''
invoked standalone. For testing, you might call plug-in main with testing parameters,
but you would first need to import the proper PyGimp modules,
so its unless your plugin doesn't do much with Gimp,
its easier to test invoked from Gimp.
'''
pass
[/undefined]


[undefined=undefined]
#! /usr/bin/python

'''
This file contains examples, or templates, of registering plugins using gimpfu.register().
This is for GIMP Python programmers, not users.
When installed, this one file puts many demo plugins into GIMP.
The demo plugins don't do much except make an appearance.

These demonstrate various combinations of:
- where plugins appear (or not) in the menus (or elsewhere) in GIMP
- when the plugin's menu items are enabled (sensitive)
- what parameters a plugin_main() receives
- whether a plugin opens a GUI dialog for user to choose options (set parameters.)

Using the gimpfu module of GIMP Python is simpler
than registering a plugin using GIMP PDB procedures (e.g. gimp.pdb.gimp_install_procedure()).
But there are bewildering many combinations.

This file makes many plugins for you to test,
when this file is installed in your local plugins directory.
The plugins are scattered around the GIMP GUI.
They are named plugin_1 through plugin_8.
To see EXACTLY what parameters are passed to each plugin, use the Help>Plugin Browser
and search for "1" thru "8".
(But note that the Plugin Browser will say a plugin takes a run-mode parameter
yet GIMP Python hides that parameter i.e. doesn't pass it to your plugin,
but instead: might display dialogs, might retrieve the last arguments,
and passes your plugin the proper set of arguments as dictated by the run-mode.)

Search for !!! to see the important differences among these plugins.

Copyright 2010 Lloyd Konneker

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
'''

from gimpfu import *


'''
Creates a new pulldown menu in the GIMP menu bar labeled "Somewhere".
Plugin appears in the Somewhere pulldown menu (submenu.)
Menu item is "plugin_1"
Menu item only enabled if any image is open.
No image or drawable are passed to the plugin.
'''
def plugin_func1(args): # !!! no image or drawable
gimp.pdb.gimp_message("Done")
print args # to the console if GIMP is run from a terminal

register(
"plugin_1_pdb",
"This is plugin_1",
"help",
"author",
"copyright",
"year",
"plugin_1...", # !!! If it opens a dialog, a GUI standard is that it have trailing ellipsis (...)
"*",
[
(PF_STRING, "arg", "The argument", "default-value")
],
[],
plugin_func1,
menu="<Image>/Somewhere") # !!! Creates new submenu in menubar, since Somewhere is not a Placeholder


'''
Appears in the "Filters" menu (usually at the bottom?)
Menu item is "plugin_2"
Menu item is only enabled if any image is open.
No dialog box opens.
No parameters are passed to the plugin.
'''
def plugin_func2(): # !!! No image or drawable or run-mode
gimp.pdb.gimp_message("Done") # !!! This appears in the status bar, not in a separate message dialog ???
print "2"

register(
"plugin_2_pdb",
"This is plugin_2",
"help",
"author",
"copyright",
"year",
"plugin_2", # no GUI dialog, so no ellipsis
"*", # !!! Only enabled if image is open
[], # no arguments
[],
plugin_func2,
menu="<Image>/Filters/") # !!! optional keyword arg


'''
Appears in the "Filters>Blur" menu (usually at the bottom?)
Menu item is "plugin_3"
Menu item is only enabled if any image is open.
A dialog box opens to get "The argument".
An image and drawable are passed to the plugin.
'''
def plugin_func3(image, drawable, args):
# !!! image and drawable passed to plugin though not declared in register()
gimp.pdb.gimp_message("Done")
print "3", args

register(
"plugin_3_pdb",
"This is plugin_3",
"help",
"author",
"copyright",
"year",
"<Image>/Filters/Blur/plugin_3...",
"*",
[
(PF_STRING, "arg", "The argument", "default-value")
],
[],
plugin_func3
)


'''
Appears in the "Filters" menu (usually at the bottom?)
Menu item is "plugin_4"
Menu item is enabled even if no image is open.
!!! If no image is open when you invoke the plugin,
a dialog box opens to get image and drawable and "The argument".
An image and drawable are passed to the plugin.

!!! You probably don't want this.
If the plugin needs an image, instead set the imagetype to "*" or similar
so that the plugin would not be enabled unless an image was open.
If the plugin does not need an image,
instead use the keyword parameter menu="<Image>/Filters/"
(and take the image and drawable parameters out of plugin_func4())
so that no image and drawable are ever passed.
'''
def plugin_func4(image, drawable, args):
# !!! image and drawable passed to plugin though not declared in register()
gimp.pdb.gimp_message("Done")
print "4", args

register(
"plugin_4_pdb",
"This is plugin_4",
"help",
"author",
"copyright",
"year",
"<Image>/Filters/plugin_4...",
"", # !!! Always enabled, even if no image is open.
[
(PF_STRING, "arg", "The argument", "default-value")
],
[],
plugin_func4
)


'''
Appears in the "Filters" menu !!! in the same group as, Python-Fu.
(I guess that: to direct a menu item to a named group,
look in the GIMP source file menus/image-menu.xml.in for a "Placeholder" name.)
Menu item is "plugin_5"
Menu item is enabled even if no image is open.
A dialog box opens to get "The argument".
No image and drawable are passed to the plugin.
'''
def plugin_func5(args):
# !!! No image or drawable passed
gimp.pdb.gimp_message("Done")
print "5", args
'''
!!! Call plugin_4 but use the current options for it
and do not open a dialog for plugin_4.

!!! Here a string "foo" must be passed but is ignored by plugin_4
and plugin_4 uses whatever string the user last entered
or its default (if the user has not run plugin_4 previously in the GIMP session.)

!!! Here you use underbar, not dash, since gimpfu mangles names.
Use the Procedure Browser to see it registered as "python-fu-plugin-4-pdb".
Mangling means: gimpfu prefixes the name with "python-fu" (if not already so)
and while in Python, uses the name with underbars instead of dashes,
but actually installs it in the PDB with dashes in the name.

(Here, pass None for image and drawable since plugin_4 wants them,
but we don't have real ones to pass in this example.)

You could use run-mode=RUN_NONINTERACTIVE.
Then the plugin_4 would use the parameters you pass.
'''
gimp.pdb.python_fu_plugin_4_pdb( None, None, "foo", run_mode=RUN_WITH_LAST_VALS)

register(
"plugin_5_pdb",
"This is plugin_5",
"help",
"author",
"copyright",
"year",
"plugin_5...",
"", # !!! Always enabled, even if no image is open
[
(PF_STRING, "arg", "The argument", "default-value")
],
[],
plugin_func5,
menu = "<Image>/Filters/Languages/" # !!! Languages puts it in a menu group
# not in a submenu Languages
)


'''
An "engine" plugin.
Does not appear in any menu.
You can create a keyboard shortcut to it, or call it from another plugin.
A dialog box opens to get "The argument".
No image and drawable are passed to the plugin.

Note that it DOES appear in Plugin Browser, as the first plugin, but with a blank name.
It DOES appear in Edit>Keyboard Shortcuts>Plugins> as "python-fu-plugin-6-pdb",
(which, unlike other plugins that appear in Keyboard Shortcuts,
is NOT the label of the plugin's menu item, but the name of the PDB procedure.)
'''
def plugin_func6(args):
# !!! No image and drawable passed to plugin
gimp.pdb.gimp_message("Done")
print "6", args

register(
"plugin_6_pdb",
"This is plugin_6",
"help",
"author",
"copyright",
"year",
"", # !!! no menu presence
"", # !!! This is moot, since there is no presence in the GUI, it can't be enabled/disabled
[
(PF_STRING, "arg", "The argument", "default-value")
],
[],
plugin_func6,
# menu="<Image>" # !!! Moot, since menu item is blank, but keeps image and drawable from being passed
)


'''
A plugin in the menubar.
No image and drawable are passed to the plugin.

!!! Note that it sometimes takes two clicks to activate.
It actually is a submenu to itself.
Sometimes the first click activates the submenu (that only has one item, that becomes highlighted.)
The second click activates the menu item and calls the plugin.
At other times, (if you have recently been hunting in the menubar)
holding the mouse over the item highlights the item and a first click activates it.
I suppose this is a quirk of gtk: an item in a menubar is a button which activates a pulldown menu,
two separate widgets but each of them consume a click?
Because of this, you probably should not use this, since it would confuse most users:
"I click on it but nothing happens."
'''
def plugin_func6b(args):
# !!! No image and drawable passed to plugin
gimp.pdb.gimp_message("Done")
print "6b", args

register(
"plugin_6b_pdb",
"This is plugin_6b",
"help",
"author",
"copyright",
"year",
"Plugin6b...", # !!! No submenu defined
"*", # !!! Only enabled if an image of any type is open
[
(PF_STRING, "arg", "The argument", "default-value")
],
[],
plugin_func6b,
menu="<Image>" # !!! In the main GIMP menubar, beneath the root of the menu hierarchy.
)


'''
An image saver, known as a "save handler."
This was derived from /usr/lib/gimp/2.0/plug-ins/colorxhtml.py
Appears in the list presented by "Select File Type" widget in the "Save Image" dialog
after you choose File>Save As.
Enabled if an image is open.

Most plugin writers will never use this.
New filetypes don't come along often.
Also, most saving to files requires dealing with binary data and demands high performance,
so is written in C.
'''
def plugin_func7(image, drawable, filename, rawfilename):
# !!! image, drawable, and two file parameters, though not declared in register()

# Here you would save the image to the file.
gimp.pdb.gimp_message("Done")
print "7"

def register_save():
gimp.register_save_handler("file-plugin_7-save", "filetypesuffix7", "")
# !!! the suffix is appended to the filename when saved, e.g. "foo.filetypesuffix7"
# Also knows as the file extension.
# More typically e.g. "filename.html"

register(
"file-plugin_7-save", # !!! Best to follow convention "file-filetype-save"
# and should match the name passed register_save_handler()
# If you don't follow the convention, gimpfu might mangle this name
# and you yourself would have to mangle the name passed to register_save_handler.
# See comments above about name mangling.
"This is plugin_7",
"help",
"author",
"copyright",
"year",
"<Save>/plugin7 file type", # !!! <Save> indicates a "save handler"
# "plugin7 file type" is the description of the file type, appears in the list of file types
# e.g. "Color XHTML" or "Graphics Interchange Format"
"*", # !!! Enabled regardless of image type RGB, Grayscale, etc.
[], # !!! No params declared (or allowed?)
# If you need to ask user for more params for saving,
# follow the template of colorxhtml.py
[],
plugin_func7,
on_query=register_save # !!! another keyword param to register(), see register_save() above
)


'''
An image loader, known as a "load handler.
See the comments above for an image saver.
Often, a load_handler and save_handler come in pairs.

See the plugin for "Open Raster" file formats, i.e. file-ora.py, for an alternative template.

(This code does install a plugin, but gives a warning:
GIMP-Error: save handler "file-plugin8-load" does not take the standard save handler args
that I don't understand.)
'''

def plugin_func8(filename, rawfilename):
# !!! Just two file parameters though not declared in register()

# In this example, you can't get here from there, since no files with extension
# "filetypesuffix8" will probably exist on your computer
# (and the Open Image dialog won't proceed until user chooses file.)

# Here you would load an image from a file and return the image.
gimp.pdb.gimp_message("Done")
print "8"

def register_load_handlers():
gimp.register_load_handler("file-plugin8-load", "filetypesuffix8", "")
# !!! the suffix filters files appearing in the "Open Image" dialog
pdb['gimp-register-file-handler-mime']("file-plugin8-load", 'image/filetypesuffix8')
# pdb['gimp-register-thumbnail-loader']("file-plugin8-load", "")


register(
"file-plugin8-load", # !!! Best to follow convention "file-filetype-load"
# and should match the name passed register_load_handler().
# If you don't follow the convention, gimpfu might mangle this name
# and you yourself would have to mangle the name passed to register_load_handler.
"This is plugin_8",
"help",
"author",
"copyright",
"year",
"<Load>/plugin8 file type", # !!! <Load> indicates a "load handler"
# "plugin8 file type" is the description of the file type, appears in the list of file types
"*", # !!! Moot. You can load an image of any type anytime.
[], # !!! No params declared (or allowed? Might be a limitation of gimpfu?)
[(PF_IMAGE, 'image', 'Output image')], # !!! A loader must return a name for the image it loaded.
plugin_func8,
on_query=register_load_handlers # !!! another keyword param to register(), see register_load() above
)


'''
This main() is defined in gimpfu.
It calls gimp.main(), which calls the proper PDB procedures to install this plugin.
'''
main()
[/undefined]
Find all posts by this user
Quote this message in a reply
Feb 25, 2014, 20:26
Post: #2
RE: Sample plugins not showing up at all.
I have even tried putting them in the global plug-in directory (C:\Program Files\GIMP-2.0\lib\gimp\2.0\plug-ins). I'm running Gimp 2.6 on Windows XP.
Find all posts by this user
Quote this message in a reply
Feb 25, 2014, 21:24
Post: #3
RE: Sample plugins not showing up at all.
I was going to post the same query about Gimp 2.6 and python installation, but I see Ofnuts note.

info about installation here.

http://www.gimpusers.com/tutorials/insta...-6-windows

Since you have to uninstall gimp, install python, reinstall gimp, a better way is to install Gimp 2.8.10.

** https://www.gimp-forum.net/ now answering questions**
Find all posts by this user
Quote this message in a reply
Feb 25, 2014, 21:36 (This post was last modified: Feb 25, 2014 21:37 by oconzer.)
Post: #4
RE: Sample plugins not showing up at all.
So it sounds like 2.8 is going to be the easiest way then. The only issue that I have with 2.8 is I tried it a while back, and did not like how things changed from the look of 2.6 and couldn't find a way to change them to look like 2.6. The other issue I had with 2.8 is that my scripts I wrote with script-fu also stopped working.

Guess I'll have to deal with it. : (

EDIT:
Have to ask if the stuff I made for custom brushes and what not are compatible with 2.8 gimp or if I have to redo them all.
Find all posts by this user
Quote this message in a reply
Feb 25, 2014, 21:52
Post: #5
RE: Sample plugins not showing up at all.
Hi,
If by the look of to 2.8 vs 2.6 you might be referring to the new 'single window' mode.
Just go to the Window menu in Gimp, and un-check the 'Single Window mode'.
Most scripts written in 2.6 should work in 2.8 and if not are pretty simple to modify.
Just post any you are having an issue with, I'd be happy to assist you. Smile
Find all posts by this user
Quote this message in a reply
Feb 25, 2014, 23:30
Post: #6
RE: Sample plugins not showing up at all.
I now remember a reason that I stuck with 2.6. The brushes of 2.8 work nothing like 2.6 and I dislike very much how they work as they mess with my custom brushes I made.
Find all posts by this user
Quote this message in a reply
Feb 26, 2014, 00:20
Post: #7
RE: Sample plugins not showing up at all.
(Feb 25, 2014 23:30)oconzer Wrote:  I now remember a reason that I stuck with 2.6. The brushes of 2.8 work nothing like 2.6 and I dislike very much how they work as they mess with my custom brushes I made.
Please elaborate. Post a sample custom brush and explain your issues.
Curious...
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Sample Colorize all layers Deskulpa 3 725 Jul 24, 2014 08:49
Last Post: rich2005
Question refocus-it not Showing in Menu talkinggoat 4 1,184 Apr 29, 2014 17:13
Last Post: rich2005
  Plugins in Batch Mode fergusondavid6 2 1,643 Jan 20, 2014 10:22
Last Post: rich2005
  G'Mic option not showing in filters DevilsAdvocate 9 5,191 Feb 2, 2013 16:37
Last Post: jayprich
  Downloading plugins angster 0 761 Oct 14, 2012 20:23
Last Post: angster

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS