Interfacing with clipboard (from Tkinter or whatever) - newbie quetion

P

Porky Pig Jr

Hello,

this question is strictly speaking is not about Python, and even not
about Tkinter, but the general concept of clipboard. yet I've done
some searches on usenet and just didn't see the group which seemed to
be right to post this question. So it goes here. I'm reading through
'Programming Python', learning Tkinter, and got into the section which
discusses the clipboard. I'm runing Python (2.3.3) on Linux, RH 9.0
with KDE. The book only says that clipboard is 'system-wide storage
repository' and talks about Windows, and how we can exchange the data
using clipboard, even if some other program knows nothing about
Tkinter.

So I've decided to give it a shot - under Linux/KDE. Ran the example
of simple editor, simpleedit.py, which implements clipboard
(interfacing from Tkinter), cut the text, and tried to place it into
different applications. VIM worked fine. KDE Notepad worked fine.
EMACS didn't work at all (seems like it's using its own clipboard?)

so I'm a bit confused here, and may be somebody can explain where does
clipboard lives on Unix. that is, is this a part of desktop manager
(such as KDE), or it will work under some more generic window manager
(such as IceWM)? Finally, does anyone know what's the story with
Emacs?


TIA
 
M

Mark 'Kamikaze' Hughes

Porky Pig Jr said:
So I've decided to give it a shot - under Linux/KDE. Ran the example
of simple editor, simpleedit.py, which implements clipboard
(interfacing from Tkinter), cut the text, and tried to place it into
different applications. VIM worked fine. KDE Notepad worked fine.
EMACS didn't work at all (seems like it's using its own clipboard?)
so I'm a bit confused here, and may be somebody can explain where does
clipboard lives on Unix. that is, is this a part of desktop manager
(such as KDE), or it will work under some more generic window manager
(such as IceWM)? Finally, does anyone know what's the story with
Emacs?

The clipboard is managed by X11, not the applications. There are two
main "selections" in X11: PRIMARY and CLIPBOARD (there's an unlimited
number of named selection buffers, but all X11 apps directly support one
or both of those). PRIMARY is filled with text when you left-drag the
mouse over it, the selection can be extended by right-clicking, and it
can be pasted by middle-clicking into a text area or terminal (like an
xterm). CLIPBOARD is set and pasted with menu or keyboard
Cut/Copy/Paste commands.

I don't use Emacs, but probably you selected and copied that text with
the keyboard, so it never got in PRIMARY, and Emacs only uses PRIMARY.

There's a very useful standard tool, xclipboard, which will display
the contents of CLIPBOARD and let you clear it, switch between multiple
buffers, paste in the contents of PRIMARY, and drag over text to copy
CLIPBOARD back to PRIMARY.

--
<a href="http://kuoi.asui.uidaho.edu/~kamikaze/"> Mark Hughes </a>
"The Oval Office carpet is thick with Presidential semen. They look out of the
window, think "I own you all" and jack off like ugly apes in humping season.
It's what they live for. No one who wants that is to be trusted. Why can't you
all /see/ that?" -Warren Ellis, _Transmetropolitan #16_
 
A

A. Lloyd Flanagan

Mark 'Kamikaze' Hughes said:
Porky Pig Jr <[email protected]>
wrote on 16 Jun 2004 16:20:13 -0700:
I don't use Emacs, but probably you selected and copied that text with
the keyboard, so it never got in PRIMARY, and Emacs only uses PRIMARY.
Actually, this is Emacs we're talking about, which means it isn't that
simple. Emacs uses its own buffer by default, but (of course) you can
customize it. In particular, there's an option "X Select Enable
Clipboard" in the customization group "Editing/Killing" which causes
emacs to use the X selection in addition to its private buffer.

If you get really ambitious, you can tell emacs which X selection to
use, but you don't want to go there if you can help it. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top