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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
|
<!DOCTYPE HTML PUBLIC "-//Norman Walsh//DTD DocBook HTML 1.0//EN">
<HTML
><HEAD
><TITLE
>Support Modules</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet"><LINK
REL="HOME"
TITLE="Gimp Python Documentation"
HREF="pygimp.html"><LINK
REL="PREVIOUS"
TITLE="Gimp Objects"
HREF="gimp-objects.html"><LINK
REL="NEXT"
TITLE="End Note"
HREF="end-note.html"></HEAD
><BODY
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Gimp Python Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="gimp-objects.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="end-note.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="SUPPORT-MODULES"
>Support Modules</A
></H1
><P
>This section describes the modules that help make using the
<TT
CLASS="FILENAME"
>gimp</TT
> module easier. These range from a set
of constants to storing persistent data.</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="GIMPENUMS-MODULE"
>The gimpenums Module</A
></H2
><P
>This module contains all the constants found in the header
<TT
CLASS="FILENAME"
>libgimp/gimpenums.h</TT
>, as well as some extra
constants that are available in Script-Fu.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1468"
>The gimpfu Module</A
></H2
><P
>This module was fully described in an earlier section. It
provides an easy interface for writing plugins, where you do not
need to worry about run_modes, GUI's and saving previous values.
It is the recommended module for writing plugins.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="GIMPPLUGIN-MODULE"
>The gimpplugin Module</A
></H2
><P
>This module provides the framework for writing Gimp
plugins in Python. It gives more flexibility for writing
plugins than the gimpfu module, but does not offer as many
features (such as automatic GUI building).</P
><P
>To use this framework you subclass
<TT
CLASS="FUNCTION"
><B
>gimpplugin.plugin</B
></TT
> like so:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>import gimpplugin
class myplugin(gimpplugin.plugin):
def init(self):
# initialisation routines
# called when gimp starts.
def quit(self):
# clean up routines
# called when gimp exits (normally).
def query(self):
# called to find what functionality the plugin provides.
gimp.install_procedure("procname", ...)
# note that this method name matches the first arg of
# gimp.install_procedure
def procname(self, arg1, ...):
# do what ever this plugin should do</PRE
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="GIMPSHELF-MODULE"
>The gimpshelf Module</A
></H2
><P
>This module gives a nicer interface to the persistent
storage interface for Gimp plugins. Due to the complicated
nature of Python objects (there is often a lot of connections
between them), it can be dificult to work out what to store in
gimp's persistent storage. The python interface only allows
storage of strings, so this module wraps pickle and unpickle to
allow persistentstorage of any python object.</P
><P
>Here is some examples of using this module:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="SCREEN"
>>>> from gimpshelf import shelf
>>> shelf['james'] = ['forty-two', (42, 42L, 42.0)]
>>> shelf.has_key('james')
1
>>> shelf['james']
['forty-two', (42, 42L, 42.0)]</PRE
></TD
></TR
></TABLE
><P
>Anything you store with
<TT
CLASS="FUNCTION"
><B
>gimpshelf.shelf</B
></TT
> will exist until Gimp
exits. This makes this interface perfect for when a plugin is
executed with the run mode
<TT
CLASS="LITERAL"
>RUN_WITH_LAST_VALS</TT
>.</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="gimp-objects.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="pygimp.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="end-note.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Gimp Objects</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
> </TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>End Note</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
|