Copy, Paste to Windows Clipboard
Quote:
> (Ben Stanley) writes:
> |> Is there a way of getting Tk to communicate
> with the Windows clipboard?
> I have exactly the same question. I found nothing in the
> FAQ (tcl/Tk on Windows)
> but I saw, that the "selection" command do not work
> between different
> Tk applications on WinNT.
The word "selection" does not appear in the Tcl/Tk On
Windows FAQ (at least not until I update it. :-). I
think you may be confusing "send" with "selection".
The selection functions do work between Windows apps and Tcl/Tk
scripts. Try the following: select some text in MS Word,
Write or any other Windows app. Copy the data to the clipboard
(inside the app). Then, enter the following at your wish prompt:
set clip [selection get -selection CLIPBOARD ]
The variable clip should now hold the data from the clipboard.
The parts that may be troublesome are that:
a.) Unix apps tend to use an active copy and paste with
the PRIMARY selection.
b.) Windows apps tend to use a passive copy and paste,
placing the data in the clipboard as an intermediary
stopping point between the applications.
c.) Motif applications on Unix do use the CLIPBOARD selection.
Decoding the Motif clipboard is a left as an exercise for
the reader.
d.) The X selection mechanism handles a lot more than text,
which introduces some interesting complexity.
All in all, Tk does pretty good with handling selections
on multiple operating systems.
The part that may be confusing you is that wish, by default,
doesn't use the Windows bindings for cut, copy and paste
(Ctrl-X, C and P, respectively, at least on English systems).
From the aforementioned FAQ, here's some relevant information:
D-5: Cut, Copy and Paste in the Tcl Console Window
The Tcl Console window uses the default bindings for the Tcl text
widget, which is not compatible with the Windows standard of
* Ctrl-x: cut
* Ctrl-c: copy
* Ctrl-v: paste
Instead, the Tcl Console window (by default) uses the following
bindings:
* Ctrl-x: deletes selected text
* Ctrl-w: cut
* Alt-w: copy
* Ctrl-y: paste
For more information on the Tcl/Tk clipboard and Windows,
see the section on Cut, Copy and Paste with the Text
Widget starting on page 169 in the book Graphical Applications
with Tcl and Tk. My Web page (the URL appears below) has
more information on this book.
I hope this helps,
-Eric
--
Eric F. Johnson URL:
http://ourworld.compuserve.com/homepages/efjohnson/
CAMAX Manufacturing Tech., Inc.
7851 Metro Parkway phone: +1 612 854 5300 fax: +1 612 854
6644