Scripter2 API: Difference between revisions

From Scribus Wiki
Jump to navigation Jump to search
No edit summary
(link to https://scribus-scripter.readthedocs.org/en/latest/)
 
(19 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[Category:Scribus]]
Scripter2 API is described below. This is a reference for the actual documentation of new scripter.  
==Document API==
Document API is the primary access point to active document in Scribus. A DocumentAPI object may be created as '''Scripter.activeDocument'''. This will return an object of type DocumentAPI. The following methods/properties are available in DocumentAPI.


See also rather : https://scribus-scripter.readthedocs.org/en/latest/


The new Scripter is composed of different modules, which are either accessible externally, or via methods of other apis.


==Layer API==
==Scripter==
===<u>Properties</u>===
====activeDocument====


:This property return '''DocumentAPI''' object.


:Usage:


==Object API==
::''document = Scripter.activeDocument''


need changes!
::Here '''document''' will represent the active document, and is of type '''DocumentAPI'''


QString '''createRect'''(double x, double y, double width, double height, QString name);
====activeWindow====
:This property return '''WindowAPI''' object.


QString '''createEllipse'''(double x, double y, double width, double height, QString name);
:Usage:
::''window = Scripter.activeWindow''


QString '''createImage'''(double x, double y, double width, double height, QString name);
:: Here, '''window''' will represent the active window, and is of type '''WindowAPI'''. See WindowAPI for methods and properties available for this object.
====colors====
:This property will return a '''list''' of default colors in Scribus, each color as an object of '''ScColorWrapper'''.


QString '''createText'''(double x, double y, double width, double height, QString name);
:Usage:
::''colors = Scripter.colors''
::''for i in colors:''
:::''print i.name''
:Result:
:::''Black''
:::''Blue''
:::''Cool Black''
:::''Cyan''
:::''Green''
:::''Magenta''
:::''Red''
:::''Registration''
:::''Rich Black''
:::''Warm Black''
:::''White''
:::''Yellow''
===Methods===
====openDocument====
====newDocument====


QString '''createTable'''(double x, double y, double width, double height, int numRows, int numColumns, QString name);
==Document API==
 
===Properties===
QString '''createLine'''(double x1, double y1, double x2, double y2, QString name);
====name====
 
====available====
QString '''createPolyLine'''(QList<QVariant> list, QString name);
====margins====
 
====modified====
QString '''createPolygon'''(QList<QVariant> list, QString name);
====activePage====
 
====pageCount====
QString '''createBezierLine'''(QList<QVariant> list, QString name);
====activeItem====
 
====dimensions====
QString '''createPathText'''(double x, double y, QString textbox, QString beziercurve, QString name);
====items====
 
====selection====
void '''deleteObject'''(QString name);
====selectionCount====
 
====colors====
void '''textFlowMode'''(QString name, int stat);
====layers====
 
====masterPages====
bool '''objectExists'''(QString name);
====styles====
 
void '''setStyle'''(QString style, QString name);
 
QList<QVariant> '''getAllStyles'''();
 
void '''duplicateObject'''(QString name);
 
void '''moveObject'''(double dx, double dy, QString name);
 
void '''moveObjectAbs'''(double x, double y, QString name);
 
void '''rotateObject'''(double rot, QString name);
 
void '''rotateObjectAbs'''(double rot, QString name);
 
void '''sizeObject'''(double width, double height, QString name);
 
QString '''getSelectedObject'''(int nr);
 
long '''selectionCount'''();
 
void '''selectObject'''(QString name);
 
void '''deselectAll'''();
 
QString '''groupObjects'''(QList<QVariant> list);
 
void '''unGroupObjects'''(QString name);
 
void '''scaleGroup'''(double factor, QString name);
 
void '''loadImage'''(QString filename, QString name);


void '''scaleImage'''(double x, double y, QString name);
===Methods===
* save
* saveAs(name)
* setInformation(author, title, comment)


void '''setImageOffset'''(double x, double y, QString name);
====Layer Methods in activeDocument====
* newLayer
* removeLayer
* getActiveLayer
* getActiveLayerName
* setActiveLayer


void '''setImageScale'''(double x, double y, QString name);
=====Color Methods in activeDocument=====
* newColorCMYK
* newColorRGB
* getColor


void '''setImageBrightness'''(double n, QString name);
=====Printer method =====
* Printer


void '''setImageGrayscale'''(QString name);
=====Image Export methods=====
* supportedImageTypes
* exportAsImages


bool '''lockObject'''(QString name);
===Margins API===
====Properties====
* top
* left
* right
* bottom


bool '''isLocked'''(QString name);
===Dimensions API===
====Properties====
* width
* height


void '''setScaleImageToFrame'''(bool scaletoframe, bool Proportional, QString name);
===Page API===
====Properties====
* number
* items
* position
* selection
====Methods====
* newRectangle
* newEllipse
* newImage
* newText
* newLine
* placeSVG
* placeODG
* placeEPS
* placeSXD
* savePageAsEPS


void '''flipObject'''(bool h, bool v, QString name);
===Layer API===
====Properties====
=== Getter functions ===
* name
* id
QString '''getObjectType'''(QString name);
* level
* printable
QString '''getFillColor'''(QString name);
* viewable
* editable
double '''getFillTransparency'''(QString name);
* flowControl
* outlineMode
int '''getBlendMode'''(QString name);
* transparency
* blendMode
QString '''getLineColor'''(QString name);
* active
double '''getLineTransparency'''(QString name);
int '''getLineBlendMode'''(QString name);
int '''getLineWidth'''(QString name);
int '''getLineShade'''(QString name);
int '''getLineJoin'''(QString name);
int '''getLineCap'''(QString name);
int '''getLineStyle'''(QString name);
int '''getFillShade'''(QString name);
int '''getCornerRadius'''(QString name);
QList<QVariant> '''getImageScale'''(QString name);
QString '''getImageName'''(QString name);


QList<QVariant> '''getPosition'''(QString name);
===Color API===
====Properties====
QList<QVariant> '''getSize'''(QString name);
* name
* spotColor
int '''getRotation'''(QString name);
====Methods====
* changeCMYK
QList<QVariant> '''getAllObjects'''();
* changeRGB
* replace
* remove


==Page API==
===Printer API===
==Color API==

Latest revision as of 10:00, 14 June 2013

Scripter2 API is described below. This is a reference for the actual documentation of new scripter.

See also rather : https://scribus-scripter.readthedocs.org/en/latest/

The new Scripter is composed of different modules, which are either accessible externally, or via methods of other apis.

Scripter

Properties

activeDocument

This property return DocumentAPI object.
Usage:
document = Scripter.activeDocument
Here document will represent the active document, and is of type DocumentAPI

activeWindow

This property return WindowAPI object.
Usage:
window = Scripter.activeWindow
Here, window will represent the active window, and is of type WindowAPI. See WindowAPI for methods and properties available for this object.

colors

This property will return a list of default colors in Scribus, each color as an object of ScColorWrapper.
Usage:
colors = Scripter.colors
for i in colors:
print i.name
Result:
Black
Blue
Cool Black
Cyan
Green
Magenta
Red
Registration
Rich Black
Warm Black
White
Yellow

Methods

openDocument

newDocument

Document API

Properties

name

available

margins

modified

activePage

pageCount

activeItem

dimensions

items

selection

selectionCount

colors

layers

masterPages

styles

Methods

  • save
  • saveAs(name)
  • setInformation(author, title, comment)

Layer Methods in activeDocument

  • newLayer
  • removeLayer
  • getActiveLayer
  • getActiveLayerName
  • setActiveLayer
Color Methods in activeDocument
  • newColorCMYK
  • newColorRGB
  • getColor
Printer method
  • Printer
Image Export methods
  • supportedImageTypes
  • exportAsImages

Margins API

Properties

  • top
  • left
  • right
  • bottom

Dimensions API

Properties

  • width
  • height

Page API

Properties

  • number
  • items
  • position
  • selection

Methods

  • newRectangle
  • newEllipse
  • newImage
  • newText
  • newLine
  • placeSVG
  • placeODG
  • placeEPS
  • placeSXD
  • savePageAsEPS

Layer API

Properties

  • name
  • id
  • level
  • printable
  • viewable
  • editable
  • flowControl
  • outlineMode
  • transparency
  • blendMode
  • active

Color API

Properties

  • name
  • spotColor

Methods

  • changeCMYK
  • changeRGB
  • replace
  • remove

Printer API