First shot at my GimpHelpers module. Registering a script is now down to:
class FullDialog(HelpedPlugin):
procedures=[
ProcedureDescription(
'full-dialog',
'RGB*, GRAY*', Gimp.ProcedureSensitivityMask.DRAWABLE,
fullDialog,
args=[
Boolean( 'boolean', _('Boolean'), _('Boolean arg'), True),
Brush( 'brush', _('Brush'), _('Brush arg'), _('Confetti')),
# This one defined above because it can contain other useful data
choiceDemo,
Channel( 'channel', _('Channel'), _('Channel arg')),
Color( 'color', _('Color'), _('Color arg'), Gegl.Color.new('red'), hasAlpha=True),
Color( 'color2', _('Color2'), _('Color arg2'), Gegl.Color.new('blue'), hasAlpha=False),
Double( 'double', _('Double'), _('Double arg'), 0, 100, 50),
Drawable( 'drawable', _('Drawable'), _('Drawable arg')),
File( 'file', _('File'), _('File arg')),
Font( 'font', _('Font'), _('Font arg'), _('Monospace Bold Italic'),noneOK=False),
Gradient( 'gradient', _('Gradient'), _('Gradient arg'), _('Sunrise')),
# 'image-' because 'image' is already used by the standard argument
Image( 'image-', _('Image'), _('Image arg'), noneOK=False),
Int( 'int', _('Integer'), _('Integer arg'), -10, 10, 0),
Layer( 'layer', _('Layer'), _('Layer arg'), noneOK=False),
Palette( 'palette', _('Palette'), _('Palette arg'), _('Ega')),
Pattern( 'pattern', _('Pattern'), _('Pattern arg'), _('Nops')),
String( 'string', _('String'), _('String arg'), _('Déjà vu')),
],
menuLabel=_('Full demo'),
menuPath=['<Image>/'+_('Test'), '<Layers>'], # Added to two menus
descShort=_('Show all widgets for Python dialogs'),
descLong=_('Show all widgets for Python dialogs, to demonstrate the gimphelpers module'),
beforeDialog=beforeFullDialog,
afterDialog=afterFullDialog,
)]
domain=getDomain(__file__)
icon=getIcon(__file__)
author='Ofnuts'
year='2024'
Gimp.main(FullDialog.__gtype__, sys.argv)
and for that price your code is wrapped into a some more code that shows the dialog (with optional peek/tweak at args before/after dialog, starts/end an undo group, and runs the code within a try/except block so that the plugin exits nicely in most cases.
The module is here.