Cut/paste buffer in Tk (Perl Tk) 
Author Message
 Cut/paste buffer in Tk (Perl Tk)

I am trying to write a small app to do something with the contents of the
cut&paste buffer, allowing me to grab things from news or mail, etc., and
essentially toss them into a bucket. I cannot find anything in the Tcl/Tk
book that would indicate how this is done with the event bindings. Can
someone point me in the right direction?

Randy
--
^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^
Randy J. Ray -- U S WEST Technologies IAD/CSS/DPDS         Phone: (303)607-5268

I don't suffer from insanity.  I enjoy every minute of it.



Sun, 21 Sep 1997 03:00:00 GMT  
 Cut/paste buffer in Tk (Perl Tk)

Quote:

>I am trying to write a small app to do something with the contents of the
>cut&paste buffer, allowing me to grab things from news or mail, etc., and
>essentially toss them into a bucket. I cannot find anything in the Tcl/Tk
>book that would indicate how this is done with the event bindings. Can
>someone point me in the right direction?

>Randy

NOTE, the following may not work under tk3.6, only tk4.0, I can't recall

If, by cut&paste buffer, you mean the X PRIMARY or CLIPBOARD selections,
then you can do the following:

selection get -selection PRIMARY  # Gets the currently selected string
or
selection get -selection CLIPBOARD # Gets the clipboard string

Now, I don't know of a way to introduce a binding such that your code
is signalled when the selection changes, other than:

selection own -selection CLIPBOARD
selection handle -selection CLIPBOARD -command DoThisCallback  # syntax
# is probably wrong here,
proc DoThisCallback {} {
        selection own -selection CLIPBOARD

Quote:
}

#the idea is that you always own the selection, and when it is taken
away from you, you demand it back.  NOTE: THIS IS VERY ANTI-SOCIAL
unless it is understood that your application is acting as a clipboard.

-----------------------------------
Paul D. Boyer
SAIC
Annapolis, MD
"So what's wrong with tax breaks for the rich?"



Sun, 21 Sep 1997 03:00:00 GMT  
 Cut/paste buffer in Tk (Perl Tk)

:
:I am trying to write a small app to do something with the contents of the
:cut&paste buffer, allowing me to grab things from news or mail, etc., and
:essentially toss them into a bucket. I cannot find anything in the Tcl/Tk
:book that would indicate how this is done with the event bindings. Can
:someone point me in the right direction?
:

Assuming we are talking Tk-b3 ...

$top = MainWindow->new();

...

This works with just about any X application:

 $seln = $top->SelectionGet();  # primary 'highlighted' selection

This works with those that do copy/paste in the 'normal' way:

 $clip = $top->SelectionGet(-selection => 'CLIPBOARD');  # Copy/paste buffer

You can use any widget on same Screen/Display as the selection not just $top.



Mon, 22 Sep 1997 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. cut and paste using perl script

2. Cut & Paste with Perl

3. Wanted: perl scripts to emulate cut and paste (Unix utility programs)

4. what Tk Tk/perl Tkperl perl/Tk?

5. Perl -> paste buffer

6. Copy/paste on Win95 with Tk

7. Pasting text inside a Tk Interface

8. cut and paste between windows programs

9. Cut And Paste Application on the web?

10. anyone have cut/paste scripts (UNIX mimics)?

11. fast cut,paste,bin2int script

12. cut and paste problem

 

 
Powered by phpBB® Forum Software