1clipboard(n) Tk Built-In Commands clipboard(n)
2
3
4
5______________________________________________________________________________
6
8 clipboard - Manipulate Tk clipboard
9
11 clipboard option ?arg arg ...?
12_________________________________________________________________
13
14
16 This command provides a Tcl interface to the Tk clipboard, which stores
17 data for later retrieval using the selection mechanism (via the -selec‐
18 tion CLIPBOARD option). In order to copy data into the clipboard,
19 clipboard clear must be called, followed by a sequence of one or more
20 calls to clipboard append. To ensure that the clipboard is updated
21 atomically, all appends should be completed before returning to the
22 event loop.
23
24 The first argument to clipboard determines the format of the rest of
25 the arguments and the behavior of the command. The following forms are
26 currently supported:
27
28 clipboard clear ?-displayof window?
29 Claims ownership of the clipboard on window's display and
30 removes any previous contents. Window defaults to ``.''.
31 Returns an empty string.
32
33 clipboard append ?-displayof window? ?-format format? ?-type type? ?--?
34 data
35 Appends data to the clipboard on window's display in the form
36 given by type with the representation given by format and claims
37 ownership of the clipboard on window's display.
38
39 Type specifies the form in which the selection is to be returned
40 (the desired ``target'' for conversion, in ICCCM terminology),
41 and should be an atom name such as STRING or FILE_NAME; see the
42 Inter-Client Communication Conventions Manual for complete
43 details. Type defaults to STRING.
44
45 The format argument specifies the representation that should be
46 used to transmit the selection to the requester (the second col‐
47 umn of Table 2 of the ICCCM), and defaults to STRING. If format
48 is STRING, the selection is transmitted as 8-bit ASCII charac‐
49 ters. If format is ATOM, then the data is divided into fields
50 separated by white space; each field is converted to its atom
51 value, and the 32-bit atom value is transmitted instead of the
52 atom name. For any other format, data is divided into fields
53 separated by white space and each field is converted to a 32-bit
54 integer; an array of integers is transmitted to the selection
55 requester. Note that strings passed to clipboard append are
56 concatenated before conversion, so the caller must take care to
57 ensure appropriate spacing across string boundaries. All items
58 appended to the clipboard with the same type must have the same
59 format.
60
61 The format argument is needed only for compatibility with clip‐
62 board requesters that don't use Tk. If the Tk toolkit is being
63 used to retrieve the CLIPBOARD selection then the value is con‐
64 verted back to a string at the requesting end, so format is
65 irrelevant.
66
67 A -- argument may be specified to mark the end of options: the
68 next argument will always be used as data. This feature may be
69 convenient if, for example, data starts with a -.
70
71 clipboard get ?-displayof window? ?-type type?
72 Retrieve data from the clipboard on window's display. window │
73 defaults to ".". Type specifies the form in which the data is │
74 to be returned and should be an atom name such as STRING or │
75 FILE_NAME. Type defaults to STRING. This command is equivalent │
76 to selection get -selection CLIPBOARD.
77
79 Get the current contents of the clipboard.
80 if {[catch {clipboard get} contents]} {
81 # There were no clipboard contents at all
82 }
83
84 Set the clipboard to contain a fixed string.
85 clipboard clear
86 clipboard append "some fixed string"
87
88
90 selection(n)
91
92
94 clear, format, clipboard, append, selection, type
95
96
97
98Tk 8.4 clipboard(n)