10.6. Podmeni Python-Fu

By default this submenu just contains the Python-Fu console.

Python-Fu is a set of Python modules that act as a wrapper to libgimp allowing the writing of plug-ins for GIMP.

10.6.1. Activating the Submenu

You can access this command from the main menu through FiltersDevelopmentPython-Fu.

10.6.2. Konzola Python-Fu

The Python-Fu console is a dialog window running a Python shell (a Python interpreter in interactive mode). This console is set up to make use of the internal GIMP library routines of libgimp.

You can use the Python-Fu console to interactively test Python commands.

The console consists of a large scrollable main window for input and output, where you can type Python commands. When you type in a Python command and then press the Enter key, the command is executed by the Python interpreter. The command's output as well as its return value (and its error message, if any) will be displayed in the main window.

Slika 16.233. Konzola Python-Fu

Konzola Python-Fu

Gumbi konzole Python-Fu

Shrani

This command lets you save the content of the main window, that is the Python-Fu console input and output (including the >>> prompt).

Počisti

When you click on this button, the content of the main window will be removed. Note that you can't get back the removed content using the Save command.

Prebrskaj

When clicked, the procedure browser pops up, with an additional button Apply at the bottom of the window.

When you press this Apply button in the procedure browser, a call to the selected procedure will be pasted into the console window as a Python command:

Applied PDB procedure

Now you just have to replace the parameter names (here: width, height, and type) with actual values, e.g.

image = pdb.gimp_image_new(400, 300, RGB)

Then press Enter to execute the command.

You can (and should!) use the constants you find in the description of the procedure's parameters, for example RGB-IMAGE or OVERLAY-MODE. But note that you have to replace hyphens (-) with underscores (_): RGB_IMAGE, OVERLAY_MODE.

[Namig] Namig

Python-Fu is not limited to just calling procedures from the PDB (GIMP procedural database). To create a new image object like in the example above, you can also type

              image = gimp.Image(width, height, type)
            

(with actual values for width, height, and type).

Zapri

S pritiskom gumba zaprete konzolo.