File: usersguide-8.html

package info (click to toggle)
sketch 0.6.13-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,284 kB
  • ctags: 8,453
  • sloc: python: 34,711; ansic: 16,543; makefile: 83; sh: 26
file content (90 lines) | stat: -rw-r--r-- 3,454 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<html>
<head>
<title>User's Guide: The Script Registry
</title>
</head>
<body bgcolor=white text=black link=blue vlink=navy alink=red>
<TABLE WIDTH="100%">
<TR>
<TH ALIGN="left" WIDTH="33%"><img SRC="Images/arrow-left.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Prev"></TH>
<TH ALIGN="center" WIDTH="33%"><img SRC="Images/arrow-up.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Up"></TH>
<TH ALIGN="right" WIDTH="33%"><img SRC="Images/arrow-right.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Next"></TH>
</TR>
<TR>
<TD ALIGN="left"><A HREF="usersguide-7.html">The Example Scripts</A></TD>
<TD ALIGN="center"><A HREF="usersguide-5.html">User Scripting
</A></TD>
<TD ALIGN="right"><A HREF="usersguide-9.html">Sketch's API
</A></TD>
</TR>
</TABLE>
<HR NOSHADE>
<H2><FONT face="Helvetica,Arial"><A NAME="N1"></A>The Script Registry
</font></H2>

<P>The script registry contains all user scripts and its contents are used
to create the <b>Script</b> menu. The script registry is implemented in
the (sub-)package <CODE>Sketch.Scripting</CODE>. Because the <CODE>Scripting</CODE>
package is not automatically imported by the <CODE>Sketch</CODE> package, you
have to <CODE>import Sketch.Scripting</CODE> explicitly before accessing the
registry functions.</P>
<P>Functions in the registry package:</P>
<P>
<DL>
<DT><B><A NAME="N2"></A><tt>AddFunction(<i>name</i>, <i>title</i>, <i>function</i>[, <i>kwargs</i>])</tt></B><DD>
<P>Add the function <i>function</i> to the registry under the name
<i>name</i>. <i>name</i> is used internally to identify the script
and should be unique. </P>
<P>The parameter <i>title</i> defines the text for the menu-entry.</P>
<P>The function accepts these optional keyword arguments:</P>
<P>
<DL>
<DT><B><CODE>script_type = <i>type</i></CODE></B><DD>
<P>The type of the script. It can be either <CODE>SafeScript</CODE>
or <CODE>AdvancedScript</CODE>. Both values are defined in the
<CODE>Scripting</CODE> package. The default is <CODE>SafeScript</CODE>.</P>

<DT><B><CODE>menu = <i>menu_spec</i></CODE></B><DD>
<P>Defines the sub-menu the script should appear in. The
<i>menu_spec</i> can be either a string or a tuple of
strings. Each string is the title of a sub-menu.</P>

<DT><B><CODE>args = <i>argtuple</i></CODE></B><DD>
<P>Defines additional positional parameters passed to the
script function after the context parameter.
<i>argtuple</i> must be a tuple containing these
arguments. It defaults to the empty tuple.</P>
</DL>
</P>

</DL>
</P>
<P>Example: Registering the <CODE>abut_horizontal</CODE> script in the sub-menu
<CODE>"Arrange"</CODE></P>
<P>
<table width="100%" cellpadding="10"><tr><td bgcolor="#FFFFD0">
<PRE>
Sketch.Scripting.AddFunction('abut_horizontal', 'Abut Horizontal',
                             abut_horizontal, menu = 'Arrange')
</PRE>
</td></tr></table>
</P>


<HR NOSHADE>
<TABLE WIDTH="100%">
<TR>
<TD ALIGN="left"><A HREF="usersguide-7.html">The Example Scripts</A></TD>
<TD ALIGN="center"><A HREF="usersguide-5.html">User Scripting
</A></TD>
<TD ALIGN="right"><A HREF="usersguide-9.html">Sketch's API
</A></TD>
</TR>
<TR>
<TH ALIGN="left" WIDTH="33%"><img SRC="Images/arrow-left.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Prev"></TH>
<TH ALIGN="center" WIDTH="33%"><img SRC="Images/arrow-up.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Up"></TH>
<TH ALIGN="right" WIDTH="33%"><img SRC="Images/arrow-right.png" WIDTH="16" HEIGHT="16" ALIGN="top" ALT="Next"></TH>
</TR>
</TABLE>
</body>
</html>