You are here

Register with variables (Python)

I'm trying to personalize a gimp script. Script should only create a copyright text on an image.

I found out that we could write some code into ~/ Code is this
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from datetime import *


d =

MySelf = {
'CopyRight':'(©) 2009 Hans-G. Normann',
'Name':'Hans-G. Normann',
'IsoDate': d.isoformat(),

del sys>/code> if we type import user into our Gimp script, then this exutes ~/ But if I Use Variable MySelf, then script will be loaded without error message, but during execute it will be shown with expected content but with clicking OK it is stressing GIMP Needs a lot of CPU resources). I have to kill the GIMP process.

Replace Variables with normal text, runs without errors.

# Register with The Gimp
#crashing version
register( "hans_kurs0040",
"Kurs PyGimp, Lektion 0040",
"pyGimp Kurs",
"Hans-G. Normann",
"/Python-Fu/Kurs/Lektion 0040",
[ (PF_FONT, 'hans_font', "Copyright Font", user.MySelf['Font']),
(PF_SLIDER, 'hans_size', "Font Size", user.MySelf['FontSize'], [1,300,1]),
(PF_STRING, 'hans_text', "Copyright", user.MySelf['CopyRight'])

#This is ok
register( "hans_kurs0041",
"Kurs PyGimp, Lektion 0041",
"pyGimp Kurs",
"Hans-G. Normann",
"(c) 2009 H. G. Normann",
"/Python-Fu/Kurs/Lektion 0041",
[ (PF_FONT, 'hans_font', "Copyright Font", 'Utopia'),
(PF_SLIDER, 'hans_size', "Font Size", 10, [1,300,1]),
(PF_STRING, 'hans_text', "Copyright", "(c) 2009 H. G. Normann")

Question: Is it possible to use Variables for register function?

Regardless of the current problem you're having... copyright and date are supposed to be static values, making them adjust to the user kinda defeats their pupose.

What's the reason for setting them to variables?

It was my idea, to customize scripts based on current login without changing of code. It should be possible that more then one person running same scripts with different default values. Do you have an other solution? Because I started programming in pygimp weeks before, I'm interested in find out what's possible and what's not. My problem is, I have no experience to find out is it a bug or only impossible.

Yes it's possible, for example register( "python-fu-photolab-addborder", Photolab_addborder_description, Photolab_addborder_help, "Raymond Ostertag", "GPL License", "2009", _("Add border"), "*", Standalone_parameters + Photolab_addborder_parameters + Standalone_export_parameters, [], python_fu_photolab_addborder, menu="/Filters"+"/"+_("Photolab"), domain=("gimp20-photolab", locale_directory) ) where Standalone_parameters could be Standalone_export_parameters = [ (PF_TOGGLE, "export", _("Export"), False), (PF_DIRNAME, "expDirectory", _("Export directory"), os.getcwd() ), ] and os.getcwd() is specific to user
Subscribe to Comments for "Register with variables (Python)"