Difference between revisions of "LazPaint scripts"

From Free Pascal wiki
Jump to navigationJump to search
(scripts)
(langue and back)
Line 1: Line 1:
 +
{{LazPaint Scripts}}
 +
 +
[[LazPaint| Go back]]
 +
 
Scripts are accessible from the '''Script''' menu. There are in Python language and stored in the ''scripts'' folder of the application.
 
Scripts are accessible from the '''Script''' menu. There are in Python language and stored in the ''scripts'' folder of the application.
  

Revision as of 07:26, 16 April 2020

English (en) français (fr)

Go back

Scripts are accessible from the Script menu. There are in Python language and stored in the scripts folder of the application.

Provided scripts

  • Channels: separate the color channels to RGB or HSL.
  • Layer effects: known layer effects like drop shadow, stroke or color overlay.
  • Mask: function to create a mask layer
  • Render: some example of using the tools from a script
  • Version: show the version of Python

How to make a script

A script is a text file with the extension .py that contains the code to run. The first line is a comment that contains the title of the script:

# My script

Or if you want it to be in a submenu:

# My folder > My script

You will need modules to communicate with Lazpaint from the script, so for example to show a message you would write:

from lazpaint import dialog

To use a function from the module:

dialog.show_message("hello world")

So here is our hello world program:

# Tutorial > Hello world program
from lazpaint import dialog
dialog.show_message("hello world")

Run a script

Run from a user folder

You can save your script in your documents and in LazPaint use Script > Run script to browse the folders.

Run from Script menu

Alternatively you can add you script to the menu of LazPaint. To do that, using administrator rights, copy the script file into the scripts folder of LazPaint:

  • On Windows: C:\Program Files\LazPaint\scripts
  • On Linux: /usr/share/lazpaint/scripts

Note that the first line must start with a # and have no spacing before. You need to restart LazPaint to update the Script menu.

Available modules

  • colors: definitions of colors and color filters
  • command: send raw commands and get version of LazPaint
  • dialog: show messages and dialog boxes
  • filters: apply filters (other than color filters)
  • image: new, load, rotate...
  • imagelist: use the imagelist window (get next image, add files)
  • layer: configure layers, access pixels
  • selection: act on the selection (in particular the blue selection)
  • tools: use the tools by providing mouse positions and key strokes
  • view: zoom and grid