/usr/share/gtk-doc/html/pygtk/class-gtkprintoperation.html is in python-gtk2-doc 2.24.0-4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>gtk.PrintOperation</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><link rel="home" href="index.html" title="PyGTK 2.0 Reference Manual"><link rel="up" href="gtk-class-reference.html" title="The gtk Class Reference"><link rel="prev" href="class-gtkprintcontext.html" title="gtk.PrintContext"><link rel="next" href="class-gtkprintoperationpreview.html" title="gtk.PrintOperationPreview"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">gtk.PrintOperation</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="class-gtkprintcontext.html">Prev</a> </td><th width="60%" align="center">The gtk Class Reference</th><td width="20%" align="right"> <a accesskey="n" href="class-gtkprintoperationpreview.html">Next</a></td></tr></table><hr></div><div class="refentry" title="gtk.PrintOperation"><a name="class-gtkprintoperation"></a><div class="titlepage"></div><div class="refnamediv"><h2>gtk.PrintOperation</h2><p>gtk.PrintOperation — a high-level printing API (new in PyGTK 2.10)</p></div><div class="refsect1" title="Synopsis"><a name="id3832400"></a><h2>Synopsis</h2><table bgcolor="#D0E0F0" width="100%"><tr><td><pre class="classsynopsis">class <span class="ooclass"><span class="classname">gtk.PrintOperation</span></span>(<span class="ooclass"><span class="classname"><PYGTKDOCLINK HREF="class-gobject">gobject.GObject</PYGTKDOCLINK></span></span>, <span class="ooclass"><span class="classname"><a class="link" href="class-gtkprintoperationpreview.html" title="gtk.PrintOperationPreview">gtk.PrintOperationPreview</a></span></span>):
<code class="constructorsynopsis"> <span class="methodname"><a class="link" href="class-gtkprintoperation.html#constructor-gtkprintoperation" title="gtk.PrintOperation">gtk.PrintOperation</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-default-page-setup" title="gtk.PrintOperation.set_default_page_setup">set_default_page_setup</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>default_page_setup</code></strong></span><span class="initializer">=None</span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--get-default-page-setup" title="gtk.PrintOperation.get_default_page_setup">get_default_page_setup</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-print-settings" title="gtk.PrintOperation.set_print_settings">set_print_settings</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>print_settings</code></strong></span><span class="initializer">=None</span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--get-print-settings" title="gtk.PrintOperation.get_print_settings">get_print_settings</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-job-name" title="gtk.PrintOperation.set_job_name">set_job_name</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>job_name</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-n-pages" title="gtk.PrintOperation.set_n_pages">set_n_pages</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>n_pages</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-current-page" title="gtk.PrintOperation.set_current_page">set_current_page</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>current_page</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-use-full-page" title="gtk.PrintOperation.set_use_full_page">set_use_full_page</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>full_page</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-unit" title="gtk.PrintOperation.set_unit">set_unit</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>unit</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-export-filename" title="gtk.PrintOperation.set_export_filename">set_export_filename</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>filename</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-track-print-status" title="gtk.PrintOperation.set_track_print_status">set_track_print_status</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>track_status</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-show-progress" title="gtk.PrintOperation.set_show_progress">set_show_progress</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>show_progress</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-allow-async" title="gtk.PrintOperation.set_allow_async">set_allow_async</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>allow_async</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-custom-tab-label" title="gtk.PrintOperation.set_custom_tab_label">set_custom_tab_label</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>label</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--run" title="gtk.PrintOperation.run">run</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>action</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>parent</code></strong></span><span class="initializer">=None</span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--get-error" title="gtk.PrintOperation.get_error">get_error</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--get-status" title="gtk.PrintOperation.get_status">get_status</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--get-status-string" title="gtk.PrintOperation.get_status_string">get_status_string</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--is-finished" title="gtk.PrintOperation.is_finished">is_finished</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--cancel" title="gtk.PrintOperation.cancel">cancel</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-support-selection" title="gtk.PrintOperation.set_support_selection">set_support_selection</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>support_selection</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--get-support-selection" title="gtk.PrintOperation.get_support_selection">get_support_selection</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-has-selection" title="gtk.PrintOperation.set_has_selection">set_has_selection</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>has_selection</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--get-has-selection" title="gtk.PrintOperation.get_has_selection">get_has_selection</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-embed-page-setup" title="gtk.PrintOperation.set_embed_page_setup">set_embed_page_setup</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>embed</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--get-embed-page-setup" title="gtk.PrintOperation.get_embed_page_setup">get_embed_page_setup</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--get-n-pages-to-print" title="gtk.PrintOperation.get_n_pages_to_print">get_n_pages_to_print</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--draw-page-finish" title="gtk.PrintOperation.draw_page_finish">draw_page_finish</a></span>(<span class="methodparam"></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-defer-drawing" title="gtk.PrintOperation.set_defer_drawing">set_defer_drawing</a></span>(<span class="methodparam"></span>)</code><br></pre></td></tr></table></div><div class="refsect1" title="Ancestry"><a name="id3833190"></a><h2>Ancestry</h2><pre class="synopsis">+-- <PYGTKDOCLINK HREF="class-gobject">gobject.GObject</PYGTKDOCLINK>
+-- <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation">gtk.PrintOperation</a> (implements <a class="link" href="class-gtkprintoperationpreview.html" title="gtk.PrintOperationPreview">gtk.PrintOperationPreview</a>)
</pre></div><div class="refsect1" title="gtk.PrintOperation Properties"><a name="properties-gtkprintoperation"></a><h2>gtk.PrintOperation Properties</h2><div class="blockquote"><table width="100%" border="0" bgcolor="#E0E0E0"><tr><td valign="top"><div class="informaltable"><table width="100%" border="0"><colgroup><col width="1in"><col width="1in"><col width="3.5in"></colgroup><tbody><tr valign="top"><td valign="top">"allow-async"</td><td valign="top">Read-Write</td><td valign="top">If <code class="literal">True</code> the print operation may run
asynchronously or not. Some systems don't support asynchronous
printing, but those that do will return
<code class="literal">gtk.PRINT_OPERATION_RESULT_IN_PROGRESS</code> as the
status, and emit the done signal when the operation is actually
done. This property is available in GTK+ 2.10 and above.</td></tr><tr valign="top"><td valign="top">"current-page"</td><td valign="top">Read-Write</td><td valign="top">The current page in the document. If this is set before
<a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--run" title="gtk.PrintOperation.run"><code class="methodname">gtk.PrintOperation.run()</code></a>,
the user will be able to select to print only the current page.
Note that this only makes sense for pre-paginated documents. This
property is available in GTK+ 2.10 and above.</td></tr><tr valign="top"><td valign="top">"custom-tab-label"</td><td valign="top">Read-Write</td><td valign="top">Used as the label of the tab containing custom widgets.
Note that this property may be ignored on some platforms. If this
is <code class="literal">None</code>, GTK+ uses a default label. This
property is available in GTK+ 2.10 and above.</td></tr><tr valign="top"><td valign="top">"default-page-setup"</td><td valign="top">Read-Write</td><td valign="top">The <a class="link" href="class-gtkpagesetup.html" title="gtk.PageSetup"><code class="classname">gtk.PageSetup</code></a>
used by default. This page setup will be used by <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--run" title="gtk.PrintOperation.run"><code class="methodname">gtk.PrintOperation.run()</code></a>,
but it can be overridden on a per-page basis by connecting to the
"request-page-setup" signal. This property is available in GTK+
2.10 and above.</td></tr><tr valign="top"><td valign="top">"export-filename"</td><td valign="top">Read-Write</td><td valign="top">The name of a file file to generate instead of showing the
print dialog. Currently, PDF is the only supported format. The
intended use of this property is for implementing "Export to PDF"
actions. "Print to PDF" support is independent of this and is
done by letting the user pick the "Print to PDF" item from the
list of printers in the print dialog. This property is available
in GTK+ 2.10 and above.</td></tr><tr valign="top"><td valign="top">"has-selection"</td><td valign="top">Read-Write</td><td valign="top">Determines whether there is a selection in your application.
This can allow your application to print the selection. This is
typically used to make a "Selection" button sensitive.
Default value: <code class="literal">False</code>
This property is available in GTK+ 2.18 and above.</td></tr><tr valign="top"><td valign="top">"job-name"</td><td valign="top">Read-Write</td><td valign="top">A string used to identify the job (e.g. in monitoring
applications like eggcups). If you don't set a job name, GTK+
picks a default one by numbering successive print jobs. This
property is available in GTK+ 2.10 and above.</td></tr><tr valign="top"><td valign="top">"n-pages"</td><td valign="top">Read-Write</td><td valign="top">The number of pages in the document. This
<span class="emphasis"><em>must</em></span> be set to a positive number before the
rendering starts. It may be set in a "begin-print" signal hander.
Note that the page numbers passed to the "request-page-setup" and
"draw-page" signals are 0-based, i.e. if the user chooses to print
all pages, the last "draw-page" signal will be for page
<em class="parameter"><code>n_pages</code></em> - 1. This property is available in
GTK+ 2.10 and above.</td></tr><tr valign="top"><td valign="top">"n-pages-to-print"</td><td valign="top">Read</td><td valign="top">The number of pages that will be printed.
Note that this value is set during print preparation phase
(<code class="literal">gtk.PRINT_STATUS_PREPARING</code>), so this value
should never be get before the data generation phase
(<code class="literal">gtk.PRINT_STATUS_GENERATING_DATA</code>).
You can connect to the "status-changed" signal and call
gtk_print_operation_get_n_pages_to_print() when print status is
<code class="literal">gtk.PRINT_STATUS_GENERATING_DATA</code>. This is
typically used to track the progress of print operation.
Default value: -1
This property is available in GTK+ 2.18 and above.</td></tr><tr valign="top"><td valign="top">"print-settings"</td><td valign="top">Read-Write</td><td valign="top">The <a class="link" href="class-gtkprintsettings.html" title="gtk.PrintSettings"><code class="classname">gtk.PrintSettings</code></a>
used for initializing the dialog. Setting this property is
typically used to re-establish print settings from a previous
print operation, see the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--run" title="gtk.PrintOperation.run"><code class="methodname">gtk.PrintOperation.run()</code></a>
method. This property is available in GTK+ 2.10 and above.</td></tr><tr valign="top"><td valign="top">"show-progress"</td><td valign="top">Read-Write</td><td valign="top">If <code class="literal">True</code> show a progress dialog during
the print operation. This property is available in GTK+ 2.10 and
above.</td></tr><tr valign="top"><td valign="top">"status"</td><td valign="top">Read</td><td valign="top">The status of the print operation. This property is
available in GTK+ 2.10 and above.</td></tr><tr valign="top"><td valign="top">"status-string"</td><td valign="top">Read</td><td valign="top">A string representation of the status of the print
operation. The string is translated and suitable for displaying
the print status e.g. in a <a class="link" href="class-gtkstatusbar.html" title="gtk.Statusbar"><code class="classname">gtk.Statusbar</code></a>.
See the "status" property for a status value that is suitable for
programmatic use. This property is available in GTK+ 2.10 and
above.</td></tr><tr valign="top"><td valign="top">"support-selection"</td><td valign="top">Read-Write</td><td valign="top">If <code class="literal">True</code>, the print operation will support print
of selection. This allows the print dialog to show a "Selection" button.
Default value: <code class="literal">False</code>
This property is available in GTK+ 2.18 and above.</td></tr><tr valign="top"><td valign="top">"track-print-status"</td><td valign="top">Read-Write</td><td valign="top">If <code class="literal">True</code>, the print operation will try to
continue report on the status of the print job in the printer
queues and printer. This can allow your application to show
things like "out of paper" issues, and when the print job actually
reaches the printer. However, this is often implemented using
polling, and should not be enabled unless needed. This property
is available in GTK+ 2.10 and above.</td></tr><tr valign="top"><td valign="top">"unit"</td><td valign="top">Read-Write</td><td valign="top">The transformation for the cairo context obtained from
<a class="link" href="class-gtkprintcontext.html" title="gtk.PrintContext"><code class="classname">gtk.PrintContext</code></a>
is set up in such a way that distances are measured in units of
<em class="parameter"><code>unit</code></em>. This property is available in GTK+
2.10 and above.</td></tr><tr valign="top"><td valign="top">"use-full-page"</td><td valign="top">Read-Write</td><td valign="top">If <code class="literal">True</code>, the transformation for the
cairo context obtained from <a class="link" href="class-gtkprintcontext.html" title="gtk.PrintContext"><code class="classname">gtk.PrintContext</code></a>
puts the origin at the top left corner of the page (which may not
be the top left corner of the sheet, depending on page orientation
and the number of pages per sheet). Otherwise, the origin is at
the top left corner of the imageable area (i.e. inside the
margins). This property is available in GTK+ 2.10 and
above.</td></tr></tbody></table></div></td></tr></table></div></div><div class="refsect1" title="gtk.PrintOperation Signal Prototypes"><a name="signal-prototypes-gtkprintoperation"></a><h2>gtk.PrintOperation Signal Prototypes</h2><p><PYGTKDOCLINK HREF="signal-prototypes-gobject">gobject.GObject Signal Prototypes</PYGTKDOCLINK></p><p><a class="link" href="class-gtkprintoperationpreview.html#signal-prototypes-gtkprintoperationpreview" title="gtk.PrintOperationPreview Signal Prototypes">gtk.PrintOperationPreview Signal Prototypes</a></p><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term">"<a class="link" href="class-gtkprintoperation.html#signal-gtkprintoperation--begin-print" title='The "begin-print" gtk.PrintOperation Signal'>begin-print</a>"</span></p></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>context</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></td></tr><tr><td><p><span class="term">"<a class="link" href="class-gtkprintoperation.html#signal-gtkprintoperation--create-custom-widget" title='The "create-custom-widget" gtk.PrintOperation Signal'>create-custom-widget</a>"</span></p></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></td></tr><tr><td><p><span class="term">"<a class="link" href="class-gtkprintoperation.html#signal-gtkprintoperation--custom-widget-apply" title='The "custom-widget-apply" gtk.PrintOperation Signal'>custom-widget-apply</a>"</span></p></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>widget</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></td></tr><tr><td><p><span class="term">"<a class="link" href="class-gtkprintoperation.html#signal-gtkprintoperation--done" title='The "done" gtk.PrintOperation Signal'>done</a>"</span></p></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>result</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></td></tr><tr><td><p><span class="term">"<a class="link" href="class-gtkprintoperation.html#signal-gtkprintoperation--draw-page" title='The "draw-page" gtk.PrintOperation Signal'>draw-page</a>"</span></p></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>context</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>page_nr</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></td></tr><tr><td><p><span class="term">"<a class="link" href="class-gtkprintoperation.html#signal-gtkprintoperation--end-print" title='The "end-print" gtk.PrintOperation Signal'>end-print</a>"</span></p></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>context</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></td></tr><tr><td><p><span class="term">"<a class="link" href="class-gtkprintoperation.html#signal-gtkprintoperation--paginate" title='The "paginate" gtk.PrintOperation Signal'>paginate</a>"</span></p></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>printoperation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>context</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></td></tr><tr><td><p><span class="term">"<a class="link" href="class-gtkprintoperation.html#signal-gtkprintoperation--preview" title='The "preview" gtk.PrintOperation Signal'>preview</a>"</span></p></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>preview</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>context</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>parent</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></td></tr><tr><td><p><span class="term">"<a class="link" href="class-gtkprintoperation.html#signal-gtkprintoperation--request-page-setup" title='The "request-page-setup" gtk.PrintOperation Signal'>request-page-setup</a>"</span></p></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>context</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>page_nr</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>setup</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></td></tr><tr><td><p><span class="term">"<a class="link" href="class-gtkprintoperation.html#signal-gtkprintoperation--status-changed" title='The "status-changed" gtk.PrintOperation Signal'>status-changed</a>"</span></p></td><td><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>printoperation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></td></tr></tbody></table></div><div class="refsect1" title="Description"><a name="id3834616"></a><h2>Description</h2><p><a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a>
is the high-level, portable printing API. It looks a bit different than
other GTK+ dialogs such as the <a class="link" href="class-gtkfilechooser.html" title="gtk.FileChooser"><code class="classname">gtk.FileChooser</code></a>,
since some platforms don't expose enough infrastructure to implement a
good print dialog. On such platforms, <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a>
uses the native print dialog. On platforms which do not provide a native
print dialog, GTK+ uses its own, see <a class="link" href="class-gtkprintunixdialog.html" title="gtkunixprint.PrintUnixDialog"><code class="classname">gtkunixprint.PrintUnixDialog</code></a>.</p><p>The typical way to use the high-level printing API is to create a
<a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a>
object with the <a class="link" href="class-gtkprintoperation.html#constructor-gtkprintoperation" title="gtk.PrintOperation"><code class="methodname">gtk.PrintOperation</code></a>
constructor when the user selects to print. Then you set some properties
on it, e.g. the page size, any <a class="link" href="class-gtkprintsettings.html" title="gtk.PrintSettings"><code class="classname">gtk.PrintSettings</code></a>
from previous print operations, the number of pages, the current page,
etc.</p><p>Then you start the print operation by calling the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--run" title="gtk.PrintOperation.run"><code class="methodname">gtk.PrintOperation.run()</code></a>
method. It will then show a dialog, let the user select a printer and
options. When the user finished the dialog various signals will be
emitted on the <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a>,
the main one being "draw-page", which you are supposed to catch and
render the page on the provided <a class="link" href="class-gtkprintcontext.html" title="gtk.PrintContext"><code class="classname">gtk.PrintContext</code></a>
using Cairo.</p><div class="example"><a name="id3834723"></a><p class="title"><b>Example 3. The high-level printing API</b></p><div class="example-contents"><pre class="programlisting">
settings = None
def do_print():
print_op = gtk.PrintOperation()
if settings != None:
print_op.set_print_settings(settings)
print_op.connect("begin_print", begin_print)
print_op.connect("draw_page", draw_page)
res = print_op.run(gtk.PRINT_OPERATION_ACTION_PRINT_DIALOG, main_window)
if res == gtk.PRINT_OPERATION_RESULT_APPLY:
settings = print_op.get_print_settings()
</pre></div></div><br class="example-break"><p>Printing support was added in GTK+ 2.10.</p></div><div class="refsect1" title="Constructor"><a name="id3834749"></a><h2>Constructor</h2><div class="refsect2" title="gtk.PrintOperation"><a name="constructor-gtkprintoperation"></a><h3>gtk.PrintOperation</h3><pre class="programlisting"><code class="constructorsynopsis"> <span class="methodname">gtk.PrintOperation</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a new <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a></td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This constructor is available in PyGTK 2.10 and above.</p></div><p>Creates a new <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a>.</p></div></div><div class="refsect1" title="Methods"><a name="id3834833"></a><h2>Methods</h2><div class="refsect2" title="gtk.PrintOperation.set_default_page_setup"><a name="method-gtkprintoperation--set-default-page-setup"></a><h3>gtk.PrintOperation.set_default_page_setup</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_default_page_setup</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>default_page_setup</code></strong></span><span class="initializer">=None</span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>default_page_setup</code></strong> :</span></p></td><td>a <a class="link" href="class-gtkpagesetup.html" title="gtk.PageSetup"><code class="classname">gtk.PageSetup</code></a>,
or <code class="literal">None</code></td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">set_default_page_setup</code>() method
makes <em class="parameter"><code>default_page_setup</code></em> the default page
setup.</p><p>This page setup will be used by the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--run" title="gtk.PrintOperation.run"><code class="methodname">gtk.PrintOperation.run()</code></a>
method, but it can be overridden on a per-page basis by connecting to
the "request-page-setup" signal.</p></div><div class="refsect2" title="gtk.PrintOperation.get_default_page_setup"><a name="method-gtkprintoperation--get-default-page-setup"></a><h3>gtk.PrintOperation.get_default_page_setup</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_default_page_setup</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>the default page setup</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">get_default_page_setup</code>() method
returns the default page setup, see the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-default-page-setup" title="gtk.PrintOperation.set_default_page_setup"><code class="methodname">gtk.PrintOperation.set_default_page_setup()</code></a>
method.</p></div><div class="refsect2" title="gtk.PrintOperation.set_print_settings"><a name="method-gtkprintoperation--set-print-settings"></a><h3>gtk.PrintOperation.set_print_settings</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_print_settings</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>print_settings</code></strong></span><span class="initializer">=None</span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>print_settings</code></strong> :</span></p></td><td><a class="link" href="class-gtkprintsettings.html" title="gtk.PrintSettings"><code class="classname">gtk.PrintSettings</code></a>,
or <code class="literal">None</code></td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">set_print_settings</code>() method sets
the print settings. This is typically used to re-establish print
settings from a previous print operation, see the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--run" title="gtk.PrintOperation.run"><code class="methodname">gtk.PrintOperation.run()</code></a>
method.</p></div><div class="refsect2" title="gtk.PrintOperation.get_print_settings"><a name="method-gtkprintoperation--get-print-settings"></a><h3>gtk.PrintOperation.get_print_settings</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_print_settings</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>the current print settings.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">get_print_settings</code>() method returns
the current print settings.</p><p>Note that the return value is <code class="literal">None</code> until
either the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-print-settings" title="gtk.PrintOperation.set_print_settings"><code class="methodname">gtk.PrintOperation.set_print_settings()</code></a>
or <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--run" title="gtk.PrintOperation.run"><code class="methodname">gtk.PrintOperation.run()</code></a>
methods have been called.</p></div><div class="refsect2" title="gtk.PrintOperation.set_job_name"><a name="method-gtkprintoperation--set-job-name"></a><h3>gtk.PrintOperation.set_job_name</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_job_name</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>job_name</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>job_name</code></strong> :</span></p></td><td>a string that identifies the print
job</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">set_job_name</code>() method sets the name
of the print job. The name is used to identify the job (e.g. in
monitoring applications like eggcups).</p><p>If you don't set a job name, GTK+ picks a default one by
numbering successive print jobs.</p></div><div class="refsect2" title="gtk.PrintOperation.set_n_pages"><a name="method-gtkprintoperation--set-n-pages"></a><h3>gtk.PrintOperation.set_n_pages</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_n_pages</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>n_pages</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>n_pages</code></strong> :</span></p></td><td>the number of pages</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">set_n_pages</code>() >method sets the
number of pages in the document. </p><p>This <span class="emphasis"><em>must</em></span> be set to a positive number
before the rendering starts. It may be set in a "begin-print" signal
hander.</p><p>Note that the page numbers passed to the "request-page-setup"
and "draw-page" signals are 0-based, i.e. if the user chooses to print
all pages, the last "draw-page" signal will be for page
<em class="parameter"><code>n_pages</code></em> - 1.</p></div><div class="refsect2" title="gtk.PrintOperation.set_current_page"><a name="method-gtkprintoperation--set-current-page"></a><h3>gtk.PrintOperation.set_current_page</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_current_page</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>current_page</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>current_page</code></strong> :</span></p></td><td>the current page, 0-based</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">set_current_page</code>() method sets the
current page.</p><p>If this is called before <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--run" title="gtk.PrintOperation.run"><code class="methodname">gtk.PrintOperation.run()</code></a>,
the user will be able to select to print only the current page.</p><p>Note that this only makes sense for pre-paginated
documents.</p></div><div class="refsect2" title="gtk.PrintOperation.set_use_full_page"><a name="method-gtkprintoperation--set-use-full-page"></a><h3>gtk.PrintOperation.set_use_full_page</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_use_full_page</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>full_page</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>full_page</code></strong> :</span></p></td><td><code class="literal">True</code> to set up the <a class="link" href="class-gtkprintcontext.html" title="gtk.PrintContext"><code class="classname">gtk.PrintContext</code></a>
for the full page</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">set_use_full_page</code>() method sets the
"full-page" property to the value of
<em class="parameter"><code>full_page</code></em>. If <em class="parameter"><code>full_page</code></em>
is <code class="literal">True</code>, the transformation for the cairo context
obtained from <a class="link" href="class-gtkprintcontext.html" title="gtk.PrintContext"><code class="classname">gtk.PrintContext</code></a>
puts the origin at the top left corner of the page (which may not be
the top left corner of the sheet, depending on page orientation and
the number of pages per sheet). Otherwise, the origin is at the top
left corner of the imageable area (i.e. inside the margins).</p></div><div class="refsect2" title="gtk.PrintOperation.set_unit"><a name="method-gtkprintoperation--set-unit"></a><h3>gtk.PrintOperation.set_unit</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_unit</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>unit</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>unit</code></strong> :</span></p></td><td>the unit to use</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">set_unit</code>() method sets up the
transformation for the cairo context such distances are measured in
units of <em class="parameter"><code>unit</code></em>.</p></div><div class="refsect2" title="gtk.PrintOperation.set_export_filename"><a name="method-gtkprintoperation--set-export-filename"></a><h3>gtk.PrintOperation.set_export_filename</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_export_filename</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>filename</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>filename</code></strong> :</span></p></td><td>the filename for the exported file</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">set_export_filename</code>() method sets
up the <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a>
to generate a file instead of showing the print dialog. The intended
use of this method is for implementing "Export to PDF"
actions. Currently, PDF is the only supported format.</p><p>"Print to PDF" support is independent of this and is done by
letting the user pick the "Print to PDF" item from the list of
printers in the print dialog.</p></div><div class="refsect2" title="gtk.PrintOperation.set_track_print_status"><a name="method-gtkprintoperation--set-track-print-status"></a><h3>gtk.PrintOperation.set_track_print_status</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_track_print_status</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>track_status</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>track_status</code></strong> :</span></p></td><td>if <code class="literal">True</code> track status after
printing</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">set_track_print_status</code>() method
sets the "track-print-status" to the value of
<em class="parameter"><code>track_status</code></em>. If
<em class="parameter"><code>track_status</code></em> is <code class="literal">True</code>, the
print operation will try to continue report on the status of the print
job in the printer queues and printer. This can allow your application
to show things like "out of paper" issues, and when the print job
actually reaches the printer.</p><p>This method is often implemented using some form of polling, so
it should not be enabled unless needed.</p></div><div class="refsect2" title="gtk.PrintOperation.set_show_progress"><a name="method-gtkprintoperation--set-show-progress"></a><h3>gtk.PrintOperation.set_show_progress</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_show_progress</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>show_progress</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>show_progress</code></strong> :</span></p></td><td>if <code class="literal">True</code> show a progress
dialog</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">set_show_progress</code>() method sets the
"show-progress" property to the value of
<em class="parameter"><code>show_progress</code></em>. If
<em class="parameter"><code>show_progress</code></em> is <code class="literal">True</code>, the
print operation will show a progress dialog during the print
operation.</p></div><div class="refsect2" title="gtk.PrintOperation.set_allow_async"><a name="method-gtkprintoperation--set-allow-async"></a><h3>gtk.PrintOperation.set_allow_async</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_allow_async</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>allow_async</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>allow_async</code></strong> :</span></p></td><td>if <code class="literal">True</code> allow asynchronous
operation</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">set_allow_async</code>() method sets the
"allow-async" to the value of <em class="parameter"><code>allow_async</code></em>. If
<em class="parameter"><code>allow_async</code></em> is <code class="literal">True</code> the
<a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--run" title="gtk.PrintOperation.run"><code class="methodname">gtk.PrintOperation.run()</code></a>
may return before the print operation is completed. Note that some
platforms may not allow asynchronous operation.</p></div><div class="refsect2" title="gtk.PrintOperation.set_custom_tab_label"><a name="method-gtkprintoperation--set-custom-tab-label"></a><h3>gtk.PrintOperation.set_custom_tab_label</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_custom_tab_label</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>label</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>label</code></strong> :</span></p></td><td></td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">set_custom_tab_label</code>() method sets
the label for the tab holding custom widgets.</p></div><div class="refsect2" title="gtk.PrintOperation.run"><a name="method-gtkprintoperation--run"></a><h3>gtk.PrintOperation.run</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">run</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>action</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>parent</code></strong></span><span class="initializer">=None</span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>action</code></strong> :</span></p></td><td>the action to start - one of the <a class="xref" href="gtk-constants.html#gtk-print-operation-action-constants" title="GTK Print Operation Action Constants">GTK Print Operation Action Constants</a></td></tr><tr><td><p><span class="term"><strong class="parameter"><code>parent</code></strong> :</span></p></td><td>Transient parent of the dialog, or <code class="literal">None</code></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>the result of the print operation - one of the
<a class="xref" href="gtk-constants.html#gtk-print-operation-result-constants" title="GTK Print Operation Result Constants">GTK Print Operation Result Constants</a>. A
return value of
<code class="literal">gtk.PRINT_OPERATION_RESULT_APPLY</code> indicates that
the printing was completed successfully. In this case, it is a
good idea to obtain the used print settings with the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--get-print-settings" title="gtk.PrintOperation.get_print_settings"><code class="methodname">gtk.PrintOperation.get_print_settings()</code></a>
method and store them for reuse with the next print operation. A
value of <code class="literal">gtk.PRINT_OPERATION_RESULT_IN_PROGRESS</code>
means the operation is running asynchronously, and will emit the
"done" signal when done.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">run</code>() method runs the print
operation, by first letting the user modify print settings in the
print dialog, and then print the document.</p><p>Normally that this method does not return until the rendering of
all pages is complete. You can connect to the "status-changed" signal
to obtain some information about the progress of the print operation.
Furthermore, it may use a recursive mainloop to show the print
dialog.</p><p>If you call the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-allow-async" title="gtk.PrintOperation.set_allow_async"><code class="methodname">gtk.PrintOperation.set_allow_async()</code></a>
method or set the "allow-async" property the operation will run
asyncronously if this is supported on the platform. The "done" signal
will be emitted with the operation results when the operation is done
(i.e. when the dialog is canceled, or when the print succeeds or
fails).</p><div class="informalexample"><pre class="programlisting">
if settings != None:
print.set_print_settings( settings)
if page_setup != None:
print.set_default_page_setup(page_setup)
print.connect( "begin-print", begin_print, data)
print.connect("draw-page", draw_page, data)
res = print.run(gtk.PRINT_OPERATION_ACTION_PRINT_DIALOG, parent)
if res == gtkprint_OPERATION_RESULT_ERROR:
error_dialog = gtk.MessageDialog(parent,
gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_ERROR,
gtk.BUTTONS_CLOSE,
"Error printing file:\n")
error_dialog.connect("response", lambda w,id: w.destroy())
error_dialog.show()
elif res == gtk.PRINT_OPERATION_RESULT_APPLY:
settings = print.get_print_settings()
</pre></div></div><div class="refsect2" title="gtk.PrintOperation.get_error"><a name="method-gtkprintoperation--get-error"></a><h3>gtk.PrintOperation.get_error</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_error</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>the error message or
<code class="literal">None</code></td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">get_error</code>() method returns the
error message or <code class="literal">None</code>. Call this when the result of
a print operation is
<code class="literal">gtk.PRINT_OPERATION_RESULT_ERROR</code>, either as
returned by the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--run" title="gtk.PrintOperation.run"><code class="methodname">gtk.PrintOperation.run()</code></a>
method, or in the "done" signal handler.</p></div><div class="refsect2" title="gtk.PrintOperation.get_status"><a name="method-gtkprintoperation--get-status"></a><h3>gtk.PrintOperation.get_status</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_status</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>the status of the print
operation</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">get_status</code>() method returns the
status of the print operation as one of the <a class="xref" href="gtk-constants.html#gtk-print-status-constants" title="GTK Print Status Constants">GTK Print Status Constants</a>. Also see the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--get-status-string" title="gtk.PrintOperation.get_status_string"><code class="methodname">gtk.PrintOperation.get_status_string()</code></a>
method.</p></div><div class="refsect2" title="gtk.PrintOperation.get_status_string"><a name="method-gtkprintoperation--get-status-string"></a><h3>gtk.PrintOperation.get_status_string</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_status_string</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a string representation of the status of the
print operation</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">get_status_string</code>() method returns
a string representation of the status of the print operation. The
string is translated and suitable for displaying the print status
e.g. in a <a class="link" href="class-gtkstatusbar.html" title="gtk.Statusbar"><code class="classname">gtk.Statusbar</code></a>.</p><p>Use the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--get-status" title="gtk.PrintOperation.get_status"><code class="methodname">gtk.PrintOperation.get_status()</code></a>
method to obtain a status value that is suitable for
programmatic use.</p></div><div class="refsect2" title="gtk.PrintOperation.is_finished"><a name="method-gtkprintoperation--is-finished"></a><h3>gtk.PrintOperation.is_finished</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">is_finished</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><code class="literal">True</code>, if the print operation
is finished.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The method returns True if the print operation is
completed. This is a convenience method to find out if the print
operation is finished, either successfully
(<code class="literal">gtk.PRINT_STATUS_FINISHED</code>) or unsuccessfully
(<code class="literal">gtk.PRINT_STATUS_FINISHED_ABORTED</code>).</p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>When you enable print status tracking, the print operation can
be in a non-finished state even after done has been called, as the
operation status then tracks the print job status on the
printer.</p></div></div><div class="refsect2" title="gtk.PrintOperation.cancel"><a name="method-gtkprintoperation--cancel"></a><h3>gtk.PrintOperation.cancel</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">cancel</span>(<span class="methodparam"></span>)</code></pre><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.10 and above.</p></div><p>The <code class="methodname">cancel</code>() method cancels a running
print operation. This method may be called from a "begin-print",
"paginate" or "draw-page" signal handler to stop the currently running
print operation.</p></div><div class="refsect2" title="gtk.PrintOperation.set_support_selection"><a name="method-gtkprintoperation--set-support-selection"></a><h3>gtk.PrintOperation.set_support_selection</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_support_selection</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>support_selection</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>support_selection</code></strong> :</span></p></td><td><code class="literal">True</code> to support selection.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.22 and above.</p></div><p>The <code class="methodname">set_support_selection</code>() method sets whether "print selection" is supported by the print operation.</p></div><div class="refsect2" title="gtk.PrintOperation.get_support_selection"><a name="method-gtkprintoperation--get-support-selection"></a><h3>gtk.PrintOperation.get_support_selection</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_support_selection</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>whether the application supports print of selection.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.22 and above.</p></div><p>The <code class="methodname">get_support_selection</code>() method gets whether "print selection" is supported by the print operation.</p></div><div class="refsect2" title="gtk.PrintOperation.set_has_selection"><a name="method-gtkprintoperation--set-has-selection"></a><h3>gtk.PrintOperation.set_has_selection</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_has_selection</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>has_selection</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>has_selection</code></strong> :</span></p></td><td><code class="literal">True</code> indicates that a selection exists.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.22 and above.</p></div><p>The <code class="methodname">set_has_selection</code>() method sets whether there is a selection to print.</p></div><div class="refsect2" title="gtk.PrintOperation.get_has_selection"><a name="method-gtkprintoperation--get-has-selection"></a><h3>gtk.PrintOperation.get_has_selection</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_has_selection</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><code class="literal">True</code> when a selection exists.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.22 and above.</p></div><p>The <code class="methodname">get_has_selection</code>() method gets whether there is a selection to print.</p></div><div class="refsect2" title="gtk.PrintOperation.set_embed_page_setup"><a name="method-gtkprintoperation--set-embed-page-setup"></a><h3>gtk.PrintOperation.set_embed_page_setup</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_embed_page_setup</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>embed</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>embed</code></strong> :</span></p></td><td><code class="literal">True</code> to embed page setup selection in the GtkPrintDialog.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.22 and above.</p></div><p>The <code class="methodname">set_embed_page_setup</code>() method embeds the page size combo box and orientation combo box
into the page setup page. Selected page setup is stored as default page setup in the print operation.</p></div><div class="refsect2" title="gtk.PrintOperation.get_embed_page_setup"><a name="method-gtkprintoperation--get-embed-page-setup"></a><h3>gtk.PrintOperation.get_embed_page_setup</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_embed_page_setup</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><code class="literal">True</code> when page setup selection combos are embedded.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.22 and above.</p></div><p>The <code class="methodname">get_embed_page_setup</code>() method XXX.</p></div><div class="refsect2" title="gtk.PrintOperation.get_n_pages_to_print"><a name="method-gtkprintoperation--get-n-pages-to-print"></a><h3>gtk.PrintOperation.get_n_pages_to_print</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">get_n_pages_to_print</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>the number of pages that will be printed.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.22 and above.</p></div><p>The <code class="methodname">get_n_pages_to_print</code>() method returns the number of pages that will be printed.</p><p>Note that this value is set during print preparation phase (<code class="literal">gtk.PRINT_STATUS_PREPARING)</code>, so this
function should never be called before the data generation phase (<code class="literal">gtk.PRINT_STATUS_GENERATING_DATA</code>). You
can connect to the "status-changed" signal and call <code class="methodname">get_n_pages_to_print</code>() when print status is
<code class="literal">gtk.PRINT_STATUS_GENERATING_DATA</code>. This is typically used to track the progress of print operation.</p></div><div class="refsect2" title="gtk.PrintOperation.draw_page_finish"><a name="method-gtkprintoperation--draw-page-finish"></a><h3>gtk.PrintOperation.draw_page_finish</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">draw_page_finish</span>(<span class="methodparam"></span>)</code></pre><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.16 and above.</p></div><p>The <code class="methodname">draw_page_finish</code>() method signals that the drawing of a particular page is complete.</p><p>It is called after completion of page drawing (e.g. drawing in another thread). If
<code class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-defer-drawing" title="gtk.PrintOperation.set_defer_drawing">set_defer_drawing</a></code>()
was called before, then this function has to be called by application. In another case it is called by the library itself.</p></div><div class="refsect2" title="gtk.PrintOperation.set_defer_drawing"><a name="method-gtkprintoperation--set-defer-drawing"></a><h3>gtk.PrintOperation.set_defer_drawing</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_defer_drawing</span>(<span class="methodparam"></span>)</code></pre><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.16 and above.</p></div><p>The <code class="methodname">set_defer_drawing</code>() method sets up the print operation to wait for calling of
<code class="methodname"><a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--draw-page-finish" title="gtk.PrintOperation.draw_page_finish">draw_page_finish</a></code>()
from application. It can be used for drawing page in another thread.</p><p>This function must be called in the callback of "draw-page" signal. .</p></div></div><div class="refsect1" title="Signals"><a name="id3837572"></a><h2>Signals</h2><div class="refsect2" title='The "begin-print" gtk.PrintOperation Signal'><a name="signal-gtkprintoperation--begin-print"></a><h3>The "begin-print" gtk.PrintOperation Signal</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>context</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>operation</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a>
on which the signal was emitted</td></tr><tr><td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintcontext.html" title="gtk.PrintContext"><code class="classname">gtk.PrintContext</code></a>
for the current operation</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_param1</code></em> :</span></p></td><td>the first user parameter (if any) specified
with the <PYGTKDOCLINK HREF="method-gobject--connect"><code class="methodname">connect</code>()</PYGTKDOCLINK>
method</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional user parameters (if any)</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This signal is available in GTK+ 2.10 and above.</p></div><p>The "begin-print" signal is emitted after the user has finished
changing print settings in the dialog, before the actual rendering
starts.</p><p>A typical use for this signal is to use the parameters from the
<a class="link" href="class-gtkprintcontext.html" title="gtk.PrintContext"><code class="classname">gtk.PrintContext</code></a>
and paginate the document accordingly, and then set the number of
pages with <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-n-pages" title="gtk.PrintOperation.set_n_pages"><code class="methodname">gtk.PrintOperation.set_n_pages()</code></a>.</p></div><div class="refsect2" title='The "create-custom-widget" gtk.PrintOperation Signal'><a name="signal-gtkprintoperation--create-custom-widget"></a><h3>The "create-custom-widget" gtk.PrintOperation Signal</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>operation</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a> on which the signal was emitted</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_param1</code></em> :</span></p></td><td>the first user parameter (if any) specified
with the <PYGTKDOCLINK HREF="method-gobject--connect"><code class="methodname">connect</code>()</PYGTKDOCLINK>
method</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional user parameters (if any)</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>A custom widget that gets embedded in the print
dialog, or <code class="literal">None</code></td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This signal is available in GTK+ 2.10 and above.</p></div><p>The "create-custom-widget" signal is emitted when displaying the
print dialog. If you return a widget in a handler for this signal it
will be added to a custom tab in the print dialog. You typically
return a container widget with multiple widgets in it.</p><p>The print dialog owns the returned widget, and its lifetime
isn't controlled by the app. However, the widget is guaranteed to stay
around until the "custom-widget-apply" signal is emitted on the
operation. Then you can read out any information you need from the
widgets.</p></div><div class="refsect2" title='The "custom-widget-apply" gtk.PrintOperation Signal'><a name="signal-gtkprintoperation--custom-widget-apply"></a><h3>The "custom-widget-apply" gtk.PrintOperation Signal</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>widget</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>operation</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a> on which the signal was emitted</td></tr><tr><td><p><span class="term"><em class="parameter"><code>widget</code></em> :</span></p></td><td>the custom widget added in create-custom-widget</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_param1</code></em> :</span></p></td><td>the first user parameter (if any) specified
with the <PYGTKDOCLINK HREF="method-gobject--connect"><code class="methodname">connect</code>()</PYGTKDOCLINK>
method</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional user parameters (if any)</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This signal is available in GTK+ 2.10 and above.</p></div><p>The "custom-widget-apply" signal is emitted right before
"begin-print" if you added a custom widget in the
"create-custom-widget" handler. When you get this signal you should
read the information from the custom widgets, as the widgets are not
guaraneed to be around at a later time.</p></div><div class="refsect2" title='The "done" gtk.PrintOperation Signal'><a name="signal-gtkprintoperation--done"></a><h3>The "done" gtk.PrintOperation Signal</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>result</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>operation</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a> on which the signal was emitted</td></tr><tr><td><p><span class="term"><em class="parameter"><code>result</code></em> :</span></p></td><td>the result of the print operation</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_param1</code></em> :</span></p></td><td>the first user parameter (if any) specified
with the <PYGTKDOCLINK HREF="method-gobject--connect"><code class="methodname">connect</code>()</PYGTKDOCLINK>
method</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional user parameters (if any)</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This signal is available in GTK+ 2.10 and above.</p></div><p>The "done" signal is emitted when the print operation run has
finished doing everything required for
printing. <em class="parameter"><code>result</code></em> (one of the <a class="xref" href="gtk-constants.html#gtk-print-operation-result-constants" title="GTK Print Operation Result Constants">GTK Print Operation Result Constants</a>) gives
you information about what happened during the run. If
<em class="parameter"><code>result</code></em> is
<code class="literal">gtk.PRINT_OPERATION_RESULT_ERROR</code> then you can call
the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--get-error" title="gtk.PrintOperation.get_error"><code class="methodname">gtk.PrintOperation.get_error()</code></a>
method for more information.</p><p>If you enabled print status tracking then the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--is-finished" title="gtk.PrintOperation.is_finished"><code class="methodname">gtk.PrintOperation.is_finished()</code></a>
method may still return <code class="literal">False</code> after this was
emitted.</p></div><div class="refsect2" title='The "draw-page" gtk.PrintOperation Signal'><a name="signal-gtkprintoperation--draw-page"></a><h3>The "draw-page" gtk.PrintOperation Signal</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>context</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>page_nr</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>operation</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a> on which the signal was emitted</td></tr><tr><td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintcontext.html" title="gtk.PrintContext"><code class="classname">gtk.PrintContext</code></a> for the current operation</td></tr><tr><td><p><span class="term"><em class="parameter"><code>page_nr</code></em> :</span></p></td><td>the number of the currently printed page</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_param1</code></em> :</span></p></td><td>the first user parameter (if any) specified
with the <PYGTKDOCLINK HREF="method-gobject--connect"><code class="methodname">connect</code>()</PYGTKDOCLINK>
method</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional user parameters (if any)</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This signal is available in GTK+ 2.10 and above.</p></div><p>The "draw-page" signal is emitted for every page that is
printed. The signal handler must render the
<em class="parameter"><code>page_nr</code></em>'s page onto the cairo context obtained
from <em class="parameter"><code>context</code></em> using <a class="link" href="class-gtkprintcontext.html#method-gtkprintcontext--get-cairo-context" title="gtk.PrintContext.get_cairo_context"><code class="methodname">gtk.PrintContext.get_cairo_context()</code></a>.</p><div class="informalexample"><pre class="programlisting">
def draw_page(operation, context, page_nr, user_data):
cr = context.get_cairo_context()
width = context.get_width()
cr.rectangle(0, 0, width, HEADER_HEIGHT)
cr.set_source_rgb(0.8, 0.8, 0.8);
cr.fill()
layout = context.create_pango_layout()
desc = pango.FontDescription("sans 14")
layout.set_font_description(desc)
layout.set_text("some text")
layout.set_width(width)
layout.set_alignment(pango.ALIGN_CENTER)
x,layout_height = layout.get_size()
text_height = layout_height / pango.SCALE
cr.move_to(width / 2, (HEADER_HEIGHT - text_height) / 2)
cr.show_layout(layout)
</pre></div><p>Use the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-use-full-page" title="gtk.PrintOperation.set_use_full_page"><code class="methodname">gtk.PrintOperation.set_use_full_page()</code></a>
and <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-unit" title="gtk.PrintOperation.set_unit"><code class="methodname">gtk.PrintOperation.set_unit()</code></a>
methods before starting the print operation to set up the
transformation of the cairo context according to your
needs.</p></div><div class="refsect2" title='The "end-print" gtk.PrintOperation Signal'><a name="signal-gtkprintoperation--end-print"></a><h3>The "end-print" gtk.PrintOperation Signal</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>context</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>operation</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a> on which the signal was emitted</td></tr><tr><td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintcontext.html" title="gtk.PrintContext"><code class="classname">gtk.PrintContext</code></a> for the current operation</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_param1</code></em> :</span></p></td><td>the first user parameter (if any) specified
with the <PYGTKDOCLINK HREF="method-gobject--connect"><code class="methodname">connect</code>()</PYGTKDOCLINK>
method</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional user parameters (if any)</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This signal is available in GTK+ 2.10 and above.</p></div><p>The "end-print" signal is emitted after all pages have been
rendered. A handler for this signal can clean up any resources that
have been allocated in the "begin-print" handler.</p></div><div class="refsect2" title='The "paginate" gtk.PrintOperation Signal'><a name="signal-gtkprintoperation--paginate"></a><h3>The "paginate" gtk.PrintOperation Signal</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>printoperation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>context</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>printoperation</code></em> :</span></p></td><td>the object which received the signal.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintcontext.html" title="gtk.PrintContext"><code class="classname">gtk.PrintContext</code></a>
for the current operation</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_param1</code></em> :</span></p></td><td>the first user parameter (if any) specified
with the <PYGTKDOCLINK HREF="method-gobject--connect"><code class="methodname">connect</code>()</PYGTKDOCLINK>
method</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional user parameters (if any)</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td></td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This signal is available in GTK+ 2.10 and above.</p></div><p>The "paginate" signal is emitted after the "begin-print" signal,
but before the actual rendering starts. It keeps getting emitted until
it returns <code class="literal">False</code>.</p><p>This signal is intended to be used for paginating the document
in small chunks, to avoid blocking the user interface for a long
time. The signal handler should update the number of pages using the
<a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--set-n-pages" title="gtk.PrintOperation.set_n_pages"><code class="methodname">gtk.PrintOperation.set_n_pages</code>()</a>
method, and return <code class="literal">True</code> if the document has been
completely paginated.</p><p>If you don't need to do pagination in chunks, you can simply do
it all in the "begin-print" handler, and set the number of pages from
there.</p></div><div class="refsect2" title='The "preview" gtk.PrintOperation Signal'><a name="signal-gtkprintoperation--preview"></a><h3>The "preview" gtk.PrintOperation Signal</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>preview</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>context</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>parent</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>operation</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a> on which the signal was emitted</td></tr><tr><td><p><span class="term"><em class="parameter"><code>preview</code></em> :</span></p></td><td>the <code class="literal">GtkPrintPreviewOperation</code> for the current operation</td></tr><tr><td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintcontext.html" title="gtk.PrintContext"><code class="classname">gtk.PrintContext</code></a> that will be used</td></tr><tr><td><p><span class="term"><em class="parameter"><code>parent</code></em> :</span></p></td><td>the <a class="link" href="class-gtkwindow.html" title="gtk.Window"><code class="classname">gtk.Window</code></a> to use as window parent, or <code class="literal">None</code></td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_param1</code></em> :</span></p></td><td>the first user parameter (if any) specified
with the <PYGTKDOCLINK HREF="method-gobject--connect"><code class="methodname">connect</code>()</PYGTKDOCLINK>
method</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional user parameters (if any)</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td><code class="literal">True</code> if the listener wants to take over control of the preview</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This signal is available in GTK+ 2.10 and above.</p></div><p>The "preview" signal is emitted when a preview is requested from
the native dialog. If you handle this you must set the cairo context
on the printing context.</p><p>If you don't override this, a default implementation using an
external viewer will be used.</p></div><div class="refsect2" title='The "request-page-setup" gtk.PrintOperation Signal'><a name="signal-gtkprintoperation--request-page-setup"></a><h3>The "request-page-setup" gtk.PrintOperation Signal</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>context</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>page_nr</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>setup</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>operation</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a> on which the signal was emitted</td></tr><tr><td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintcontext.html" title="gtk.PrintContext"><code class="classname">gtk.PrintContext</code></a> for the current operation</td></tr><tr><td><p><span class="term"><em class="parameter"><code>page_nr</code></em> :</span></p></td><td>the number of the currently printed page</td></tr><tr><td><p><span class="term"><em class="parameter"><code>setup</code></em> :</span></p></td><td>the <a class="link" href="class-gtkpagesetup.html" title="gtk.PageSetup"><code class="classname">gtk.PageSetup</code></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_param1</code></em> :</span></p></td><td>the first user parameter (if any) specified
with the <PYGTKDOCLINK HREF="method-gobject--connect"><code class="methodname">connect</code>()</PYGTKDOCLINK>
method</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional user parameters (if any)</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This signal is available in GTK+ 2.10 and above.</p></div><p>The "request-page-setup" signal is emitted once for every page
that is printed, to give the application a chance to modify the page
setup. Any changes done to <em class="parameter"><code>setup</code></em> will be in
force only for printing this page.</p></div><div class="refsect2" title='The "status-changed" gtk.PrintOperation Signal'><a name="signal-gtkprintoperation--status-changed"></a><h3>The "status-changed" gtk.PrintOperation Signal</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">callback</span>(<span class="methodparam"><span class="parameter"><em class="parameter"><code>operation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>printoperation</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>user_param1</code></em></span></span>, <span class="methodparam"><span class="parameter"><em class="parameter"><code>...</code></em></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><em class="parameter"><code>operation</code></em> :</span></p></td><td>the <a class="link" href="class-gtkprintoperation.html" title="gtk.PrintOperation"><code class="classname">gtk.PrintOperation</code></a> on which the signal was emitted</td></tr><tr><td><p><span class="term"><em class="parameter"><code>printoperation</code></em> :</span></p></td><td>the object which received the signal.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_param1</code></em> :</span></p></td><td>the first user parameter (if any) specified
with the <PYGTKDOCLINK HREF="method-gobject--connect"><code class="methodname">connect</code>()</PYGTKDOCLINK>
method</td></tr><tr><td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td><td>additional user parameters (if any)</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This signal is available in GTK+ 2.10 and above.</p></div><p>The "status-changed" signal is emitted at between the various
phases of the print operation. See the <a class="xref" href="gtk-constants.html#gtk-print-status-constants" title="GTK Print Status Constants">GTK Print Status Constants</a> for the phases that
are being discriminated. Use the <a class="link" href="class-gtkprintoperation.html#method-gtkprintoperation--get-status" title="gtk.PrintOperation.get_status"><code class="methodname">gtk.PrintOperation.get_status</code>()</a>
method to find out the current status.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="class-gtkprintcontext.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="gtk-class-reference.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="class-gtkprintoperationpreview.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">gtk.PrintContext </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> gtk.PrintOperationPreview</td></tr></table></div></body></html>
|