Sun May 31, 2020 9:25 am
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Purpose: Basic structure of a Python-Fu GIMP plugin.
Calling: <Image>/Filters/Shapes
Author: Herbert Nemeczek
Version: 2020-05-10
"""
from gimpfu import *
##########################################################################################
# Plug-in class.
def plugin_main(fImage, fDrawable, fX1, fY1):
return
##########################################################################################
# Registration of the Python-Fu plugin.
register(
"HN_Gimp_Plugin_PythonFu",
"Short description of the plugin.",
"Detailed description of the plugin.",
"Herbert Nemeczek (Herbert.Nemeczek@t-online.de)",
"(c) Herbert Nemeczek",
"2020-05-10",
"<Image>/Filters/Shapes/HN: GIMP-Plugin (Python-Fu)...",
"RGB*, GRAY*, INDEXED*",
[ (PF_INT, "x1", "X-coordinate: x", 0),
(PF_INT, "y1", "Y-coordinate: y", 0)
],
[],
plugin_main
)
main()
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Purpose: Basic structure of a "real" Python GIMP plugin.
Calling: <Image>/Filters/Shapes
Author: Herbert Nemeczek
Version: 2020-05-10
"""
import gimp, gimpplugin
pdb = gimp.pdb
from gimpenums import *
#
import gimpui
import pygtk, gtk
##########################################################################################
# User interface class.
class winUserInterface(gtk.Window):
#=======================================================================================
# The constructor that creates the window.
def __init__(self):
#
#-------------------------------------------------------------------------------------
# Title, size, position, .. of the window.
gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
self.set_title('Example of a "real" Python GIMP plugin')
self.winWidth = 500 ; self.winHeight = 300 # Definition of the minimum sizes
self.set_default_size(self.winWidth, self.winHeight)
self.set_position(gtk.WIN_POS_NONE) # Also possible: gtk.WIN_POS_CENTER)
self.set_border_width(10)
self.set_resizable(True)
#
#-------------------------------------------------------------------------------------
# Define container (table) for the widget elements.
self.layTab = gtk.Table(rows=7, columns=3, homogeneous=True)
self.layTab.set_border_width(5)
self.layTab.set_col_spacings(10)
self.layTab.set_row_spacings(10)
self.add(self.layTab)
#
#-------------------------------------------------------------------------------------
# Add button/key.
self.okButton = gtk.Button("OK")
self.okButton.set_relief(gtk.RELIEF_NORMAL)
self.okButton.set_tooltip_text("Performs an activity and ends the plugin.")
self.okButton.connect("clicked", self.winEvtExitClicked)
#self.horBox.pack_start(self.okButton, True, True, 0)
self.layTab.attach(self.okTaste, 1, 2, 6, 7, gtk.FILL | gtk.EXPAND, 0, 0, 0)
#
#-------------------------------------------------------------------------------------
# Close the user interface with the X button.
self.connect("destroy", self.winEvtExitClicked)
#
#=======================================================================================
# Method of displaying the window and staying in the event queue.
def showInterface(self):
self.show_all() # Now display the window built in the constructor
gtk.main() # Event queue after displaying the main window
#
#=======================================================================================
# Event in response to the key being pressed on "OK" or "X".
def winEvtExitClicked(self, widget, data=None):
gtk.main_quit() # End of the event queue that started with "gtk.main()"
##########################################################################################
# Plugin class.
class plugin_main(gimpplugin.plugin):
#
#=======================================================================================
# Usually you do not redefine the following three methods in your own plugin,
# since these are already set appropriately in the upper class. But it works.
def start(self) :
gimp.main(self.init, self.quit, self.query, self._run)
def init(self):
pass
def quit(self):
pass
#
#=======================================================================================
# Method "query(self)" is called when the plugin is recognized as new/changed.
def query(self):
pluginName = "HN_Gimp_Plugin_Python"
gimp.install_procedure(
pluginName,
"Short description of the plugin.",
"Detailed description of the plugin.",
"Herbert Nemeczek (Herbert.Nemeczek@t-online.de)",
"(c) Herbert Nemeczek",
"2020-05-10",
"HN: GIMP-Plugin (Python)...",
"RGB*, GRAY*, INDEXED*",
PLUGIN,
[ ( # Run mode (32-bit Integer)
PDB_INT32, # A plugin can be started in the following modes:
"run_mode", # RUN_INTERACTIVE (0), RUN_NONINTERACTIVE (1)
"Run mode" # and RUN_WITH_LAST_VALS (2)
),
( # Picture/Image (Image ID)
PDB_IMAGE, # Every opened picture has a single active drawing area,
"image", # the "Drawable".
"Input image"
),
( # Drawable (Drawable ID)
PDB_DRAWABLE, # A "Drawable" is a GIMP concept that contains layers,
"drawable", # but also various other objects such as channels,
"Input drawable" # layer masks and the selection mask.
)
],
[]
)
gimp.menu_register(pluginName, "<Image>/Filters/Shapes")
#
#======================================================================================
# The method "run(self)" realizes the actual plugin.
def HN_Gimp_Plugin_Python(self, fRunMode, fImage, fDrawable):
if (fRunMode == RUN_NONINTERACTIVE):
return
userInterface = winUserInterface()
# GTK: Show surface and wait until "gtk_main_quit()" is called.
userInterface.showInterface()
if (__name__ == '__main__'):
plugin_main().start()
Mon Jun 01, 2020 3:15 pm
Wed Jun 09, 2021 3:09 am
Wed Jun 09, 2021 11:15 am
Wed Sep 29, 2021 6:48 pm
Wed Sep 29, 2021 7:58 pm
Thu Sep 30, 2021 2:00 am