File: scrap.html

package info (click to toggle)
pygame 2.1.2%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 32,416 kB
  • sloc: ansic: 66,042; python: 46,176; javascript: 9,214; objc: 273; sh: 78; makefile: 56; cpp: 25
file content (458 lines) | stat: -rw-r--r-- 30,090 bytes parent folder | download
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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>pygame.scrap &#8212; pygame v2.1.2 documentation</title>
    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/pygame.css" />
    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <link rel="shortcut icon" href="../_static/pygame.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="pygame._sdl2.controller" href="sdl2_controller.html" />
    <link rel="prev" title="pygame.Rect" href="rect.html" /> 
  </head><body>  

    <div class="document">

  <div class="header">
    <table>
      <tr>
	<td class="logo">
	  <a href="https://www.pygame.org/">
	    <img src="../_static/pygame_tiny.png"/>
	  </a>
	  <h5>pygame documentation</h5>
	</td>
	<td class="pagelinks">
	  <div class="top">
	    <a href="https://www.pygame.org/">Pygame Home</a> ||
	    <a href="../index.html">Help Contents</a> ||
	    <a href="../genindex.html">Reference Index</a>

        <form action="../search.html" method="get" style="display:inline;float:right;">
          <input name="q" value="" type="text">
          <input value="search" type="submit">
        </form>
	  </div>
	  <hr style="color:black;border-bottom:none;border-style: dotted;border-bottom-style:none;">
	  <p class="bottom"><b>Most useful stuff</b>:
	    <a href="color.html">Color</a> | 
	    <a href="display.html">display</a> | 
	    <a href="draw.html">draw</a> | 
	    <a href="event.html">event</a> | 
	    <a href="font.html">font</a> | 
	    <a href="image.html">image</a> | 
	    <a href="key.html">key</a> | 
	    <a href="locals.html">locals</a> | 
	    <a href="mixer.html">mixer</a> | 
	    <a href="mouse.html">mouse</a> | 
	    <a href="rect.html">Rect</a> | 
	    <a href="surface.html">Surface</a> | 
	    <a href="time.html">time</a> | 
	    <a href="music.html">music</a> | 
	    <a href="pygame.html">pygame</a>
	  </p>

	  <p class="bottom"><b>Advanced stuff</b>:
	    <a href="cursors.html">cursors</a> | 
	    <a href="joystick.html">joystick</a> | 
	    <a href="mask.html">mask</a> | 
	    <a href="sprite.html">sprite</a> | 
	    <a href="transform.html">transform</a> | 
	    <a href="bufferproxy.html">BufferProxy</a> | 
	    <a href="freetype.html">freetype</a> | 
	    <a href="gfxdraw.html">gfxdraw</a> | 
	    <a href="midi.html">midi</a> | 
	    <a href="pixelarray.html">PixelArray</a> | 
	    <a href="pixelcopy.html">pixelcopy</a> | 
	    <a href="sndarray.html">sndarray</a> | 
	    <a href="surfarray.html">surfarray</a> | 
	    <a href="math.html">math</a>
	  </p>

	  <p class="bottom"><b>Other</b>:
	    <a href="camera.html">camera</a> | 
	    <a href="sdl2_controller.html#module-pygame._sdl2.controller">controller</a> | 
	    <a href="examples.html">examples</a> | 
	    <a href="fastevent.html">fastevent</a> | 
	    <a href="scrap.html">scrap</a> | 
	    <a href="tests.html">tests</a> | 
	    <a href="touch.html">touch</a> | 
	    <a href="pygame.html#module-pygame.version">version</a>
	  </p>
	</td>
      </tr>
    </table>
  </div>

      <div class="documentwrapper">
          <div class="body" role="main">
            
<section id="module-pygame.scrap">
<span id="pygame-scrap"></span><dl class="definition">
<dt class="title module sig sig-object">
<code class="docutils literal notranslate"><span class="pre">pygame.scrap</span></code></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">pygame module for clipboard support.</span></div>
</div>
<table class="toc docutils align-default">
<colgroup>
<col style="width: 21%" />
<col style="width: 1%" />
<col style="width: 78%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><div class="line"><a class="toc reference external" href="scrap.html#pygame.scrap.init">pygame.scrap.init</a></div>
</td>
<td>—</td>
<td>Initializes the scrap module.</td>
</tr>
<tr class="row-even"><td><div class="line"><a class="toc reference external" href="scrap.html#pygame.scrap.get_init">pygame.scrap.get_init</a></div>
</td>
<td>—</td>
<td>Returns True if the scrap module is currently initialized.</td>
</tr>
<tr class="row-odd"><td><div class="line"><a class="toc reference external" href="scrap.html#pygame.scrap.get">pygame.scrap.get</a></div>
</td>
<td>—</td>
<td>Gets the data for the specified type from the clipboard.</td>
</tr>
<tr class="row-even"><td><div class="line"><a class="toc reference external" href="scrap.html#pygame.scrap.get_types">pygame.scrap.get_types</a></div>
</td>
<td>—</td>
<td>Gets a list of the available clipboard types.</td>
</tr>
<tr class="row-odd"><td><div class="line"><a class="toc reference external" href="scrap.html#pygame.scrap.put">pygame.scrap.put</a></div>
</td>
<td>—</td>
<td>Places data into the clipboard.</td>
</tr>
<tr class="row-even"><td><div class="line"><a class="toc reference external" href="scrap.html#pygame.scrap.contains">pygame.scrap.contains</a></div>
</td>
<td>—</td>
<td>Checks whether data for a given type is available in the clipboard.</td>
</tr>
<tr class="row-odd"><td><div class="line"><a class="toc reference external" href="scrap.html#pygame.scrap.lost">pygame.scrap.lost</a></div>
</td>
<td>—</td>
<td>Indicates if the clipboard ownership has been lost by the pygame application.</td>
</tr>
<tr class="row-even"><td><div class="line"><a class="toc reference external" href="scrap.html#pygame.scrap.set_mode">pygame.scrap.set_mode</a></div>
</td>
<td>—</td>
<td>Sets the clipboard access mode.</td>
</tr>
</tbody>
</table>
<p><strong>EXPERIMENTAL!</strong>: This API may change or disappear in later pygame releases. If
you use this, your code may break with the next pygame release.</p>
<p>The scrap module is for transferring data to/from the clipboard. This allows
for cutting and pasting data between pygame and other applications. Some basic
data (MIME) types are defined and registered:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span> <span class="n">pygame</span>         <span class="n">string</span>
<span class="n">constant</span>        <span class="n">value</span>        <span class="n">description</span>
<span class="o">--------------------------------------------------</span>
<span class="n">SCRAP_TEXT</span>   <span class="s2">&quot;text/plain&quot;</span>    <span class="n">plain</span> <span class="n">text</span>
<span class="n">SCRAP_BMP</span>    <span class="s2">&quot;image/bmp&quot;</span>     <span class="n">BMP</span> <span class="n">encoded</span> <span class="n">image</span> <span class="n">data</span>
<span class="n">SCRAP_PBM</span>    <span class="s2">&quot;image/pbm&quot;</span>     <span class="n">PBM</span> <span class="n">encoded</span> <span class="n">image</span> <span class="n">data</span>
<span class="n">SCRAP_PPM</span>    <span class="s2">&quot;image/ppm&quot;</span>     <span class="n">PPM</span> <span class="n">encoded</span> <span class="n">image</span> <span class="n">data</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_PPM</span></code>, <code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_PBM</span></code> and <code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_BMP</span></code> are
suitable for surface buffers to be shared with other applications.
<code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_TEXT</span></code> is an alias for the plain text clipboard type.</p>
<p>Depending on the platform, additional types are automatically registered when
data is placed into the clipboard to guarantee a consistent sharing behaviour
with other applications. The following listed types can be used as strings to
be passed to the respective <a class="tooltip reference internal" href="#module-pygame.scrap" title=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">pygame.scrap</span></code><span class="tooltip-content">pygame module for clipboard support.</span></a> module functions.</p>
<p>For <strong>Windows</strong> platforms, these additional types are supported automatically
and resolve to their internal definitions:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s2">&quot;text/plain;charset=utf-8&quot;</span>   <span class="n">UTF</span><span class="o">-</span><span class="mi">8</span> <span class="n">encoded</span> <span class="n">text</span>
<span class="s2">&quot;audio/wav&quot;</span>                  <span class="n">WAV</span> <span class="n">encoded</span> <span class="n">audio</span>
<span class="s2">&quot;image/tiff&quot;</span>                 <span class="n">TIFF</span> <span class="n">encoded</span> <span class="n">image</span> <span class="n">data</span>
</pre></div>
</div>
<p>For <strong>X11</strong> platforms, these additional types are supported automatically and
resolve to their internal definitions:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="s2">&quot;text/plain;charset=utf-8&quot;</span>   <span class="n">UTF</span><span class="o">-</span><span class="mi">8</span> <span class="n">encoded</span> <span class="n">text</span>
<span class="s2">&quot;UTF8_STRING&quot;</span>                <span class="n">UTF</span><span class="o">-</span><span class="mi">8</span> <span class="n">encoded</span> <span class="n">text</span>
<span class="s2">&quot;COMPOUND_TEXT&quot;</span>              <span class="n">COMPOUND</span> <span class="n">text</span>
</pre></div>
</div>
<p>User defined types can be used, but the data might not be accessible by other
applications unless they know what data type to look for.
Example: Data placed into the clipboard by
<code class="docutils literal notranslate"><span class="pre">pygame.scrap.put(&quot;my_data_type&quot;,</span> <span class="pre">byte_data)</span></code> can only be accessed by
applications which query the clipboard for the <code class="docutils literal notranslate"><span class="pre">&quot;my_data_type&quot;</span></code> data type.</p>
<p>For an example of how the scrap module works refer to the examples page
(<a class="tooltip reference internal" href="examples.html#pygame.examples.scrap_clipboard.main" title=""><code class="xref py py-func docutils literal notranslate"><span class="pre">pygame.examples.scrap_clipboard.main()</span></code><span class="tooltip-content">access the clipboard</span></a>) or the code directly in GitHub
(<a class="reference external" href="https://github.com/pygame/pygame/blob/master/examples/scrap_clipboard.py">pygame/examples/scrap_clipboard.py</a>).</p>
<div class="versionadded">
<p><span class="versionmodified added">New in pygame 1.8.</span></p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The scrap module is currently only supported for Windows, X11 and Mac OS X.
On Mac OS X only text works at the moment - other types may be supported in
future releases.</p>
</div>
<dl class="py function definition">
<dt class="sig sig-object py title" id="pygame.scrap.init">
<span class="sig-prename descclassname"><span class="pre">pygame.scrap.</span></span><span class="sig-name descname"><span class="pre">init</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pygame.scrap.init" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Initializes the scrap module.</span></div>
<div class="line"><span class="signature">init() -&gt; None</span></div>
</div>
<p>Initialize the scrap module.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><a class="tooltip reference internal" href="pygame.html#pygame.error" title=""><strong>pygame.error</strong><span class="tooltip-content">standard pygame exception</span></a> -- if unable to initialize scrap module</p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The scrap module requires <a class="tooltip reference internal" href="display.html#pygame.display.set_mode" title=""><code class="xref py py-func docutils literal notranslate"><span class="pre">pygame.display.set_mode()</span></code><span class="tooltip-content">Initialize a window or screen for display</span></a> be
called before being initialized.</p>
</div>
</dd></dl>

<dl class="py function definition">
<dt class="sig sig-object py title" id="pygame.scrap.get_init">
<span class="sig-prename descclassname"><span class="pre">pygame.scrap.</span></span><span class="sig-name descname"><span class="pre">get_init</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pygame.scrap.get_init" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Returns True if the scrap module is currently initialized.</span></div>
<div class="line"><span class="signature">get_init() -&gt; bool</span></div>
</div>
<p>Gets the scrap module's initialization state.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">True</span></code> if the <a class="tooltip reference internal" href="#module-pygame.scrap" title=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">pygame.scrap</span></code><span class="tooltip-content">pygame module for clipboard support.</span></a> module is currently
initialized, <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>bool</p>
</dd>
</dl>
<div class="versionadded">
<p><span class="versionmodified added">New in pygame 1.9.5.</span></p>
</div>
</dd></dl>

<dl class="py function definition">
<dt class="sig sig-object py title" id="pygame.scrap.get">
<span class="sig-prename descclassname"><span class="pre">pygame.scrap.</span></span><span class="sig-name descname"><span class="pre">get</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pygame.scrap.get" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Gets the data for the specified type from the clipboard.</span></div>
<div class="line"><span class="signature">get(type) -&gt; bytes | None</span></div>
</div>
<p>Retrieves the data for the specified type from the clipboard. The data is
returned as a byte string and might need further processing (such as
decoding to Unicode).</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>type</strong> (<em>string</em>) -- data type to retrieve from the clipboard</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>data (bytes object) for the given type identifier or <code class="docutils literal notranslate"><span class="pre">None</span></code> if
no data for the given type is available</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bytes | None</p>
</dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">text</span> <span class="o">=</span> <span class="n">pygame</span><span class="o">.</span><span class="n">scrap</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">pygame</span><span class="o">.</span><span class="n">SCRAP_TEXT</span><span class="p">)</span>
<span class="k">if</span> <span class="n">text</span><span class="p">:</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;There is text in the clipboard.&quot;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;There does not seem to be text in the clipboard.&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function definition">
<dt class="sig sig-object py title" id="pygame.scrap.get_types">
<span class="sig-prename descclassname"><span class="pre">pygame.scrap.</span></span><span class="sig-name descname"><span class="pre">get_types</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pygame.scrap.get_types" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Gets a list of the available clipboard types.</span></div>
<div class="line"><span class="signature">get_types() -&gt; list</span></div>
</div>
<p>Gets a list of data type string identifiers for the data currently
available on the clipboard. Each identifier can be used in the
<a class="tooltip reference internal" href="#pygame.scrap.get" title=""><code class="xref py py-func docutils literal notranslate"><span class="pre">pygame.scrap.get()</span></code><span class="tooltip-content">Gets the data for the specified type from the clipboard.</span></a> method to get the clipboard content of the
specific type.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>list of strings of the available clipboard data types, if there
is no data in the clipboard an empty list is returned</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>list</p>
</dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">pygame</span><span class="o">.</span><span class="n">scrap</span><span class="o">.</span><span class="n">get_types</span><span class="p">():</span>
    <span class="k">if</span> <span class="s2">&quot;text&quot;</span> <span class="ow">in</span> <span class="n">t</span><span class="p">:</span>
        <span class="c1"># There is some content with the word &quot;text&quot; in its type string.</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">pygame</span><span class="o">.</span><span class="n">scrap</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">t</span><span class="p">))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function definition">
<dt class="sig sig-object py title" id="pygame.scrap.put">
<span class="sig-prename descclassname"><span class="pre">pygame.scrap.</span></span><span class="sig-name descname"><span class="pre">put</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pygame.scrap.put" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Places data into the clipboard.</span></div>
<div class="line"><span class="signature">put(type, data) -&gt; None</span></div>
</div>
<p>Places data for a given clipboard type into the clipboard. The data must
be a string buffer. The type is a string identifying the type of data to be
placed into the clipboard. This can be one of the predefined
<code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_PBM</span></code>, <code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_PPM</span></code>, <code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_BMP</span></code> or
<code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_TEXT</span></code> values or a user defined string identifier.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>type</strong> (<em>string</em>) -- type identifier of the data to be placed into the
clipboard</p></li>
<li><p><strong>data</strong> (<em>bytes</em>) -- data to be place into the clipboard, a bytes object</p></li>
</ul>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><a class="tooltip reference internal" href="pygame.html#pygame.error" title=""><strong>pygame.error</strong><span class="tooltip-content">standard pygame exception</span></a> -- if unable to put the data into the clipboard</p>
</dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">&quot;example.bmp&quot;</span><span class="p">,</span> <span class="s2">&quot;rb&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fp</span><span class="p">:</span>
    <span class="n">pygame</span><span class="o">.</span><span class="n">scrap</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">pygame</span><span class="o">.</span><span class="n">SCRAP_BMP</span><span class="p">,</span> <span class="n">fp</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
<span class="c1"># The image data is now on the clipboard for other applications to access</span>
<span class="c1"># it.</span>
<span class="n">pygame</span><span class="o">.</span><span class="n">scrap</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">pygame</span><span class="o">.</span><span class="n">SCRAP_TEXT</span><span class="p">,</span> <span class="sa">b</span><span class="s2">&quot;A text to copy&quot;</span><span class="p">)</span>
<span class="n">pygame</span><span class="o">.</span><span class="n">scrap</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="s2">&quot;Plain text&quot;</span><span class="p">,</span> <span class="sa">b</span><span class="s2">&quot;Data for user defined type &#39;Plain text&#39;&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function definition">
<dt class="sig sig-object py title" id="pygame.scrap.contains">
<span class="sig-prename descclassname"><span class="pre">pygame.scrap.</span></span><span class="sig-name descname"><span class="pre">contains</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pygame.scrap.contains" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Checks whether data for a given type is available in the clipboard.</span></div>
<div class="line"><span class="signature">contains(type) -&gt; bool</span></div>
</div>
<p>Checks whether data for the given type is currently available in the
clipboard.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>type</strong> (<em>string</em>) -- data type to check availability of</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">True</span></code> if data for the passed type is available in the
clipboard, <code class="docutils literal notranslate"><span class="pre">False</span></code> otherwise</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>bool</p>
</dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="n">pygame</span><span class="o">.</span><span class="n">scrap</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="n">pygame</span><span class="o">.</span><span class="n">SCRAP_TEXT</span><span class="p">):</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;There is text in the clipboard.&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">pygame</span><span class="o">.</span><span class="n">scrap</span><span class="o">.</span><span class="n">contains</span><span class="p">(</span><span class="s2">&quot;own_data_type&quot;</span><span class="p">):</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;There is stuff in the clipboard.&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function definition">
<dt class="sig sig-object py title" id="pygame.scrap.lost">
<span class="sig-prename descclassname"><span class="pre">pygame.scrap.</span></span><span class="sig-name descname"><span class="pre">lost</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pygame.scrap.lost" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Indicates if the clipboard ownership has been lost by the pygame application.</span></div>
<div class="line"><span class="signature">lost() -&gt; bool</span></div>
</div>
<p>Indicates if the clipboard ownership has been lost by the pygame
application.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">True</span></code>, if the clipboard ownership has been lost by the pygame
application, <code class="docutils literal notranslate"><span class="pre">False</span></code> if the pygame application still owns the clipboard</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>bool</p>
</dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">if</span> <span class="n">pygame</span><span class="o">.</span><span class="n">scrap</span><span class="o">.</span><span class="n">lost</span><span class="p">():</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;The clipboard is in use by another application.&quot;</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function definition">
<dt class="sig sig-object py title" id="pygame.scrap.set_mode">
<span class="sig-prename descclassname"><span class="pre">pygame.scrap.</span></span><span class="sig-name descname"><span class="pre">set_mode</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#pygame.scrap.set_mode" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Sets the clipboard access mode.</span></div>
<div class="line"><span class="signature">set_mode(mode) -&gt; None</span></div>
</div>
<p>Sets the access mode for the clipboard. This is only of interest for X11
environments where clipboard modes <code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_SELECTION</span></code> (for mouse
selections) and <code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_CLIPBOARD</span></code> (for the clipboard) are
available. Setting the mode to <code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_SELECTION</span></code> in other
environments will not change the mode from <code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_CLIPBOARD</span></code>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>mode</strong> -- access mode, supported values are <code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_CLIPBOARD</span></code>
and <code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_SELECTION</span></code> (<code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_SELECTION</span></code> only has an
effect when used on X11 platforms)</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong> -- if the <code class="docutils literal notranslate"><span class="pre">mode</span></code> parameter is not
<code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_CLIPBOARD</span></code> or <code class="docutils literal notranslate"><span class="pre">pygame.SCRAP_SELECTION</span></code></p>
</dd>
</dl>
</dd></dl>

</dd></dl>

</section>


<br /><br />
<hr />
<a href="https://github.com/pygame/pygame/edit/main/docs/reST/ref/scrap.rst" rel="nofollow">Edit on GitHub</a>
            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="sdl2_controller.html" title="pygame._sdl2.controller"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="rect.html" title="pygame.Rect"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">pygame v2.1.2 documentation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">pygame.scrap</span></code></a></li>
    <script type="text/javascript" src="https://www.pygame.org/comment/jquery.plugin.docscomments.js"></script>

      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2000-2021, pygame developers.
    </div>
  </body>
</html>